netdevsim: Implement port types and indexing
authorDmytro Linkin <dlinkin@nvidia.com>
Wed, 2 Jun 2021 12:17:16 +0000 (15:17 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 2 Jun 2021 21:08:36 +0000 (14:08 -0700)
commit814b9ce65ec3b53404eeda7a11e1abb4af8d7df3
tree106bf313e35643e9659a294a900f2ca609ab9ecf
parent32ac15d8fd804615e79e365d6825da2a371f91f9
netdevsim: Implement port types and indexing

Define type of ports, which netdevsim driver currently operates with as
PF. Define new port type - VF, which will be implemented in following
patches. Add helper functions to distinguish them. Add helper function
to get VF index from port index.

Add port indexing logic where PFs' indexes starts from 0, VFs' - from
NSIM_DEV_VF_PORT_INDEX_BASE.
All ports uses same index pool, which means that PF port may be created
with index from VFs' indexes range.
Maximum number of VFs, which the driver can allocate, is limited by
UINT_MAX - BASE.

Signed-off-by: Dmytro Linkin <dlinkin@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/netdevsim/bus.c
drivers/net/netdevsim/dev.c
drivers/net/netdevsim/netdevsim.h