bnx2x: Add Nic partitioning mode (57712 devices)
Subsystems (2)
PATCH 1/1 bnx2x: Add Nic partitioning mode (57712 devices)
NIC partitioning is another flavor of multi function - having few PCI functions share the same physical port. Unlike the currently supported mode of multi-function which depends on the switch configuration and uses outer-VLAN, the NPAR mode is switch independent and uses the MAC addresses to distribute incoming packets to the different functions. This patch adds the specific HW setting of the NPAR mode and some distinctions between switch dependent (SD) and
switch independent (SI) multi-function (MF) modes where the configuration is not the same.
Advance driver version to 1.60.00-6
--- drivers/net/bnx2x/bnx2x.h | 11 +- drivers/net/bnx2x/bnx2x_cmn.c | 34 +++- drivers/net/bnx2x/bnx2x_cmn.h | 10 + drivers/net/bnx2x/bnx2x_ethtool.c | 58 +++++-- drivers/net/bnx2x/bnx2x_hsi.h | 42 +++++- drivers/net/bnx2x/bnx2x_main.c | 336 +++++++++++++++++++++++++++++-------- drivers/net/bnx2x/bnx2x_reg.h | 5 + 7 files changed, 400 insertions(+), 96 deletions(-)
drivers/net/bnx2x/bnx2x.h +9 -2
@@ -20,8 +20,8 @@* (you will need to reboot afterwards) */ /* #define BNX2X_STOP_ON_ERROR */ -#define DRV_MODULE_VERSION "1.60.00-5" -#define DRV_MODULE_RELDATE "2010/11/24" +#define DRV_MODULE_VERSION "1.60.00-6" +#define DRV_MODULE_RELDATE "2010/11/29"#define BNX2X_BC_VER 0x040200#define BNX2X_MULTI_QUEUE
@@ -671,6 +671,10 @@ enum {CAM_ISCSI_ETH_LINE , CAM_MAX_PF_LINE = CAM_ISCSI_ETH_LINE }; +/* number of MACs per function in NIG memory - used for SI mode */ +#define NIG_LLH_FUNC_MEM_SIZE 16 +/* number of entries in NIG_REG_LLHX_FUNC_MEM */ +#define NIG_LLH_FUNC_MEM_MAX_OFFSET 8#define BNX2X_VF_ID_INVALID 0xFF
@@ -967,6 +971,8 @@ struct bnx2x {u16 mf_ov;u8 mf_mode;#define IS_MF (bp) (bp->mf_mode != 0) +#define IS_MF_SI (bp) (bp->mf_mode == MULTI_FUNCTION_SI) +#define IS_MF_SD (bp) (bp->mf_mode == MULTI_FUNCTION_SD)u8 wol;
@@ -1010,6 +1016,7 @@ struct bnx2x {#define BNX2X_ACCEPT_ALL_UNICAST 0x0004#define BNX2X_ACCEPT_ALL_MULTICAST 0x0008#define BNX2X_ACCEPT_BROADCAST 0x0010 +#define BNX2X_ACCEPT_UNMATCHED_UCAST 0x0020#define BNX2X_PROMISCUOUS_MODE 0x10000u32 rx_mode;
drivers/net/bnx2x/bnx2x_cmn.c +24 -10
@@ -698,6 +698,29 @@ void bnx2x_release_phy_lock(struct bnx2x *bp)mutex_unlock (&bp->port.phy_mutex); } +/* calculates MF speed according to current linespeed and MF configuration */ +u16 bnx2x_get_mf_speed (struct bnx2x *bp) +{ +u16 line_speed = bp->link_vars.line_speed; +if (IS_MF (bp)) { +u16 maxCfg = (bp->mf_config[BP_VN (bp)] & +FUNC_MF_CFG_MAX_BW_MASK ) >> +FUNC_MF_CFG_MAX_BW_SHIFT ; +/* Calculate the current MAX line speed limit for the DCC +* capable devices +*/ +if (IS_MF_SD (bp)) { +u16 vn_max_rate = maxCfg *100 ; + +if (vn_max_rate < line_speed) + line_speed = vn_max_rate; + }else /* IS_MF_SI(bp)) */ + line_speed = (line_speed * maxCfg) /100 ; + } + +return line_speed; +} +void bnx2x_link_report (struct bnx2x *bp) {if (bp->flags &MF_FUNC_DIS ) {
@@ -713,17 +736,8 @@ void bnx2x_link_report(struct bnx2x *bp)netif_carrier_on (bp->dev);netdev_info (bp->dev,"NIC Link is Up, " ); - line_speed = bp->link_vars.line_speed; -if (IS_MF (bp)) { -u16 vn_max_rate; + line_speed =bnx2x_get_mf_speed (bp); - vn_max_rate = - ((bp->mf_config[BP_VN (bp)] & -FUNC_MF_CFG_MAX_BW_MASK ) >> -FUNC_MF_CFG_MAX_BW_SHIFT ) *100 ; -if (vn_max_rate < line_speed) - line_speed = vn_max_rate; - }pr_cont ("%d Mbps " , line_speed);if (bp->link_vars.duplex ==DUPLEX_FULL )
drivers/net/bnx2x/bnx2x_cmn.h +10 -0
@@ -73,6 +73,16 @@ void bnx2x__link_status_update(struct bnx2x *bp);void bnx2x_link_report (struct bnx2x *bp);/** +* calculates MF speed according to current linespeed and MF +* configuration +* +* @param bp +* +* @return u16 +*/ +u16 bnx2x_get_mf_speed (struct bnx2x *bp); + +/** * MSI-X slowpath interrupt handler * * @param irq
drivers/net/bnx2x/bnx2x_ethtool.c +45 -13
85 lines not on this page · raw message
drivers/net/bnx2x/bnx2x_hsi.h +41 -1
72 lines not on this page · raw message
drivers/net/bnx2x/bnx2x_main.c +266 -70
494 lines not on this page · raw message
drivers/net/bnx2x/bnx2x_reg.h +5 -0
@@ -1774,6 +1774,8 @@/* [RW 8] event id for llh0 */ #define NIG_REG_LLH0_EVENT_ID 0x10084#define NIG_REG_LLH0_FUNC_EN 0x160fc +#define NIG_REG_LLH0_FUNC_MEM 0x16180 +#define NIG_REG_LLH0_FUNC_MEM_ENABLE 0x16140#define NIG_REG_LLH0_FUNC_VLAN_ID 0x16100/* [RW 1] Determine the IP version to look for in ~nig_registers_llh0_dest_ip_0.llh0_dest_ip_0. 0 - IPv6; 1-IPv4 */
@@ -1797,6 +1799,9 @@#define NIG_REG_LLH1_ERROR_MASK 0x10090/* [RW 8] event id for llh1 */ #define NIG_REG_LLH1_EVENT_ID 0x10088 +#define NIG_REG_LLH1_FUNC_MEM 0x161c0 +#define NIG_REG_LLH1_FUNC_MEM_ENABLE 0x16160 +#define NIG_REG_LLH1_FUNC_MEM_SIZE 16/* [RW 8] init credit counter for port1 in LLH */ #define NIG_REG_LLH1_XCM_INIT_CREDIT 0x10564#define NIG_REG_LLH1_XCM_MASK 0x10134
Signature · 1 line
1.7.1
Quoted 9 lines · Dmitry Kravkov
NIC partitioning is another flavor of multi function - having few PCI functions share the same physical port. Unlike the currently supported mode of multi-function which depends on the switch configuration and uses outer-VLAN, the NPAR mode is switch independent and uses the MAC addresses to distribute incoming packets to the different functions. This patch adds the specific HW setting of the NPAR mode and some distinctions between switch dependent (SD) and
switch independent (SI) multi-function (MF) modes where the configuration is not the same.
Just as SR-IOV introduced sysfs pointers between VF and PF devices:
/sys/bus/pci/devices/pci0000:00/0000:00:09.0/0000:05:00.0/virtfn0 -> ../0000:05:10.0/
/sys/bus/pci/devices/pci0000:00/0000:00:09.0/0000:05:10.0/physfn -> ../0000:05:00.0/
I would like to see a similar relationship exposed in sysfs for NPAR partitions and their respective ports. This will let biosdevname accurately name NPAR devices according to the scheme:
pci<slot>#<port>_<virtual function>
just as it does for SR-IOV devices. Is there one parent partition that the child partitions could point back to, or other way to group all the partitions of a single port?
Thanks,
Matt
Signature · 3 lines
Matt Domsch Technology Strategist Dell | Office of the CTO
Quoted 19 lines · Matt Domsch
Quoted 9 lines · Dmitry Kravkov
NIC partitioning is another flavor of multi function - having few PCI functions share the same physical port. Unlike the currently supported mode of multi-function which depends on the switch configuration and uses outer-VLAN, the NPAR mode is switch independent and uses the MAC addresses to distribute incoming packets to the different functions. This patch adds the specific HW setting of the NPAR mode and some distinctions between switch dependent (SD) and
switch independent (SI) multi-function (MF) modes where the configuration is not the same.Just as SR-IOV introduced sysfs pointers between VF and PF devices:
/sys/bus/pci/devices/pci0000:00/0000:00:09.0/0000:05:00.0/virtfn0 -> ../0000:05:10.0/
/sys/bus/pci/devices/pci0000:00/0000:00:09.0/0000:05:10.0/physfn -> ../0000:05:00.0/I would like to see a similar relationship exposed in sysfs for NPAR partitions and their respective ports. This will let biosdevname accurately name NPAR devices according to the scheme:
Quoted 5 lines
pci<slot>#<port>_<virtual function>
just as it does for SR-IOV devices. Is there one parent partition that the child partitions could point back to, or other way to group all the partitions of a single port?
The main difference here is that we are talking about multiple PFs - so each can be brought up or down independently of the others. So there is no one master PF that controls the port and once it is brought down, the port is down too. At any given moment, one of the PFs is acting as the port master and controls the shared HW - but once this PF is brought down, another PF is seamlessly taking over.
I think the main difference is that we have real PCI functions and not virtual ones. On the same PCI bus, we have two physical ports, and 8 physical functions - 4 on each port. I agree that exposing which functions are using the same port can really help - so I'm open to suggestions on the "how".
Thanks,
Eilon
Quoted 6 lines · Eilon Greenstein
The main difference here is that we are talking about multiple PFs - so each can be brought up or down independently of the others. So there is no one master PF that controls the port and once it is brought down, the port is down too. At any given moment, one of the PFs is acting as the port master and controls the shared HW - but once this PF is brought down, another PF is seamlessly taking over.
Hmm, that complicates things a bit.
Quoted 5 lines
I think the main difference is that we have real PCI functions and not virtual ones. On the same PCI bus, we have two physical ports, and 8 physical functions - 4 on each port. I agree that exposing which functions are using the same port can really help - so I'm open to suggestions on the "how".
We really need, for NPAR, SR-IOV, and the Chelsio multiple-ports-per-PCI-device model, a "network port" abstraction in sysfs. We need the ability to map M ports to N PCI devices, and expose that mapping in sysfs.
For SR-IOV, biosdevname follows the physfn and virtfn* pointers to map VFs to the PF. But it assumes 1 PF -> 1 port. For the Intel 1GbE and 10GbE cards I have, this is true, but nothing says it has to be true.
Maybe something like:
/sys/class/net_port/<port_name>/<ifname> -> /sys/class/net/<ifname>
/sys/class/net/<ifname>/port -> /sys/class/net_port/<port_name>
This introduces the idea of ports, though adds the complication of needing to name them somehow. But it would expose the relationship of each net interface to a specific port, as well as allow multiple interfaces per port, conceptually independent of the PCI device mapping. That way, each driver, which must know the mapping somehow, could fill these links out?
Signature · 3 lines
Matt Domsch Technology Strategist Dell | Office of the CTO
Quoted 2 lines · Matt Domsch
For SR-IOV, biosdevname follows the physfn and virtfn* pointers to map VFs to the PF.
This gives the PF a VF maps to but in general doesn't say anything about the port the VF maps to, unless you make additional assumptions as below.
Quoted 2 lines
But it assumes 1 PF -> 1 port. For the Intel 1GbE and 10GbE cards I have, this is true, but nothing says it has to be true.
Yes, there are devices for which this isn't true. You can have several PFs mapping to 1 port, 1 PF mapping to several ports, a PF mapping to some port(s) but its VFs mapping to different port(s), ...
Quoted 4 lines
Maybe something like:
/sys/class/net_port/<port_name>/<ifname> -> /sys/class/net/<ifname>
Quoted 8 lines
/sys/class/net/<ifname>/port -> /sys/class/net_port/<port_name>
This introduces the idea of ports, though adds the complication of needing to name them somehow. But it would expose the relationship of each net interface to a specific port, as well as allow multiple interfaces per port, conceptually independent of the PCI device mapping. That way, each driver, which must know the mapping somehow, could fill these links out?
/sys/class/net/<ifname>/dev_id indicates the physical port <ifname> is associated with. At least a few drivers set up dev_id this way.
Quoted 1 line · Dimitris Michailidis
Matt Domsch wrote:
...
Quoted 4 lines
/sys/class/net/<ifname>/dev_id indicates the physical port <ifname> is associated with. At least a few drivers set up
dev_idthis way.
So we are on agreement? This can satisf all needs? If so, we will add this scheme to the bnx2x as well.
Thanks,
Eilon
Quoted 10 lines · Eilon Greenstein
Quoted 1 line · Dimitris Michailidis
Matt Domsch wrote:
...
Quoted 4 lines
/sys/class/net/<ifname>/dev_id indicates the physical port <ifname> is associated with. At least a few drivers set up
dev_idthis way.So we are on agreement? This can satisf all needs? If so, we will add this scheme to the bnx2x as well.
I don't think that's enough. Necessary, but not sufficient.
If dev_id is a field that starts over with each PCI device (e.g. is used to distinguish multiple ports that share the same PCI device), that's enough to handle the Chelsio case, but not the NPAR & SR-IOV case.
If the above is true, then a value of dev_id=0 for all 1:1 PCI Device : Port relations is fine, leaving the three drivers that set dev_id non-zero are all multi-port, single PCI device controllers.
cxgb4/t4_hw.c: adap->port[i]->dev_id = j; mlx4/en_netdev.c: dev->dev_id = port - 1; sfc/siena.c: efx->net_dev->dev_id = EFX_OWORD_FIELD(reg, FRF_CZ_CS_PORT_NUM) - 1;
Is that truly how these three controllers work: they set dev_id when there are multiple physical ports that a single PCI d/b/d/f drives?
My naming convention of:
pci<slot>#<port>
wants to express this relationship. If I have a card with 2 PCI devices, and 2 physical ports on each device, I have 4 ports to describe. The dev_ids would look like: 0,1 0,1 , so I can't use that value directly. I can make a list of PCI devices on the same card, look at the dev_id field of each, and run a counter:
for each slot:
int port=1;
for each pci device:
for each in net/<interface>/dev_id:
use name pci<slot>#<port>
port++
OK? Can someone with such a card send me tree /sys, so I can see the tree does really look like I expect:
/sys/devices/pci0000:00/0000:00:1c.0/0000:0b:00.0/net/eth0/dev_id = 0 /sys/devices/pci0000:00/0000:00:1c.0/0000:0b:00.0/net/eth1/dev_id = 1
simply finding a net/ subdir under a PCI device, each of the directories in net/ are interface names, with different dev_id values.
Now for the partitioned devices (NPAR or SR-IOV). Here, we have multiple PCI devices mapped to the same port.
My naming convention of:
pci<slot>#<port>_<partition>
wants to express this relationship.
I need a way to express which port a given partition maps to. I'm also presuming this is a static mapping right now, that it won't change around during runtime (ala Xsigo, which I have no solution here for; if the mapping isn't static, this is going to get trickier).
As dev_ids are only unique per PCI device, we would need a pointer to the "base" device. However, in the Broadcom 57712 case, there is no such "base" device. :-( So, using dev_id here doesn't seem like the right approach for these devices.
What if we did something like this?
/sys/devices/net_ports/port0/ /sys/devices/pci0000:00/0000:00:1c.0/0000:0b:00.0/net/eth0/port ->
/../../../../../net_ports/port0
/sys/devices/pci0000:00/0000:00:1c.0/0000:0b:00.1/net/eth1/port ->
/../../../../../net_ports/port0In this case, the port0 "name" is simply a way to group interfaces into ports, it's not how ports are labeled on the chassis.
Do network drivers know how many ports they have?
What are the characteristics of network ports? Ideally, physical location (PCI slot), and index within that physical location. These right now I'm deriving from SMBIOS and PCI, and if not explicitly exposed, counting devices on the same slot and assigning port numbers that way, but I would love to have explicit information from the drivers.
Thoughts?
Thanks,
Matt
Signature · 3 lines
Matt Domsch Technology Strategist Dell | Office of the CTO
Quoted 23 lines · Matt Domsch
Quoted 10 lines · Eilon Greenstein
Quoted 1 line · Dimitris Michailidis
Matt Domsch wrote:
...
Quoted 4 lines
/sys/class/net/<ifname>/dev_id indicates the physical port <ifname> is associated with. At least a few drivers set up
dev_idthis way.So we are on agreement? This can satisf all needs? If so, we will add this scheme to the bnx2x as well.
I don't think that's enough. Necessary, but not sufficient.
If
dev_idis a field that starts over with each PCI device (e.g. is used to distinguish multiple ports that share the same PCI device), that's enough to handle the Chelsio case, but not the NPAR & SR-IOV case.If the above is true, then a value of dev_id=0 for all 1:1 PCI Device : Port relations is fine, leaving the three drivers that set
dev_idnon-zero are all multi-port, single PCI device controllers.
Quoted 6 lines
cxgb4/t4_hw.c: adap->port[i]->dev_id = j; mlx4/en_netdev.c: dev->dev_id = port - 1; sfc/siena.c: efx->net_dev->dev_id = EFX_OWORD_FIELD(reg, FRF_CZ_CS_PORT_NUM) - 1;Is that truly how these three controllers work: they set
dev_idwhen there are multiple physical ports that a single PCI d/b/d/f drives?
[...]
In the case of sfc, each port has a separate PCI function. We read this register field to find out which port we're talking to, as virtualisation can alter the function number. I don't know about the others.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 6 lines · Ben Hutchings
Quoted 1 line · Matt Domsch
On Thu, Dec 09, 2010 at 04:49:25PM +0200, Eilon Greenstein wrote:
In the case of sfc, each port has a separate PCI function. We read this register field to find out which port we're talking to, as virtualisation can alter the function number. I don't know about the others.
For a single card then, this makes sense.
pci<slot>#<port> where port = dev_id
If I have 2 such cards on a PCI extender though, I think this breaks. Here, I'd see duplicate dev_id values, yes?
Do you label the ports on your cards in any fashion? Do they have labels like port 0, port 1, port 2, ... ? Does it matter if we give names starting at 0, or starting at 1? latest biosdevname starts them at 1, or uses whatever value BIOS actually provides, which on systems I've tried, all start at 1.
Maybe the PCI extender case I should just ignore as being unsolvable right now... If I think N PCI devices are in the same slot, then using the dev_id value as a per-slot value is fine. If there's an extender that would break this scheme, biosdevname now returns nothing for any names it would otherwise suggest duplicate names for, essentially throwing its hands up "I don't know".
Signature · 3 lines
Matt Domsch Technology Strategist Dell | Office of the CTO
Quoted 12 lines · Matt Domsch
Quoted 6 lines · Ben Hutchings
Quoted 1 line · Matt Domsch
On Thu, Dec 09, 2010 at 04:49:25PM +0200, Eilon Greenstein wrote:
In the case of sfc, each port has a separate PCI function. We read this register field to find out which port we're talking to, as virtualisation can alter the function number. I don't know about the others.
For a single card then, this makes sense.
pci<slot>#<port> where port =
dev_id
Quoted 8 lines
If I have 2 such cards on a PCI extender though, I think this breaks. Here, I'd see duplicate
dev_idvalues, yes?Do you label the ports on your cards in any fashion? Do they have labels like port 0, port 1, port 2, ... ? Does it matter if we give names starting at 0, or starting at 1? latest biosdevname starts them at 1, or uses whatever value BIOS actually provides, which on systems I've tried, all start at 1.
[...]
Currently they aren't labelled, so far as I can aware.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 10 lines · Matt Domsch
Quoted 8 lines · Eilon Greenstein
Quoted 1 line · Dimitris Michailidis
Matt Domsch wrote:
...
Quoted 3 lines
/sys/class/net/<ifname>/dev_id indicates the physical port <ifname> is associated with. At least a few drivers set up
dev_idthis way.So we are on agreement? This can satisf all needs? If so, we will add this scheme to the bnx2x as well.
Quoted 6 lines
I don't think that's enough. Necessary, but not sufficient.
If
dev_idis a field that starts over with each PCI device (e.g. is used to distinguish multiple ports that share the same PCI device), that's enough to handle the Chelsio case, but not the NPAR & SR-IOV case.
My understanding is that dev_id indicates the physical port of the card associated with an interface. It does not reset when you move to a new function of the device.
Quoted 6 lines
If the above is true, then a value of dev_id=0 for all 1:1 PCI Device : Port relations is fine, leaving the three drivers that set
dev_idnon-zero are all multi-port, single PCI device controllers.
cxgb4/t4_hw.c: adap->port[i]->dev_id = j;
The HW cxgb4 deals with is multi-function (actually the driver uses primarily function 4 nowadays) but it's virtualizable and the association between functions and ports very flexible. For example, you may have a 2-port card but maybe the driver will be given just (a slice of) port 1. So the driver will create one netdev with dev_id==1 and there won't be anything with dev_id 0. You cannot determine this by looking at anything PCI-related or any static table.
For this driver you can get two pieces of information for an interface:
- /sys/class/net/<interface>/device points to the PCI function handling the interface
- /sys/class/net/<interface>/dev_id indicates the physical port of the interface
You can have several interfaces with same device link and different dev_id.
While the current driver doesn't do it you could also have several
interfaces with different device links but same dev_id (NPAR situation, notice again that dev_ids are not per PCI function), or interfaces with different device and dev_id, or even interfaces with same device and dev_id.
Quoted 6 lines
mlx4/en_netdev.c: dev->dev_id = port - 1; sfc/siena.c: efx->net_dev->dev_id = EFX_OWORD_FIELD(reg, FRF_CZ_CS_PORT_NUM) - 1;Is that truly how these three controllers work: they set
dev_idwhen there are multiple physical ports that a single PCI d/b/d/f drives?
Quoted 6 lines
My naming convention of:
pci<slot>#<port>
wants to express this relationship. If I have a card with 2 PCI devices, and 2 physical ports on each device, I have 4 ports to describe. Thedev_idswould look like: 0,1 0,1 , so I can't use that value directly.
I think they'd be 0,1,2,3 for drivers that set dev_id and 0,0,0,0 otherwise.
I can make a list of PCI devices on the same card,
Quoted 9 lines
look at the
dev_idfield of each, and run a counter:for each slot:
int port=1;
for each pci device:
for each in net/<interface>/dev_id:
use name pci<slot>#<port>
port++
Quoted 8 lines
OK? Can someone with such a card send me tree /sys, so I can see the tree does really look like I expect:
/sys/devices/pci0000:00/0000:00:1c.0/0000:0b:00.0/net/eth0/dev_id = 0 /sys/devices/pci0000:00/0000:00:1c.0/0000:0b:00.0/net/eth1/dev_id = 1
simply finding a
net/subdir under a PCI device, each of the directories innet/are interface names, with differentdev_idvalues.
This would be the common case but in general the dev_ids don't need to be consecutive or start at 0, nor does a particular dev_id need to appear just once.
Quoted 12 lines
Now for the partitioned devices (NPAR or SR-IOV). Here, we have multiple PCI devices mapped to the same port.
My naming convention of:
pci<slot>#<port>_<partition>
wants to express this relationship.I need a way to express which port a given partition maps to. I'm also presuming this is a static mapping right now, that it won't change around during runtime (ala Xsigo, which I have no solution here for; if the mapping isn't static, this is going to get trickier).
Quoted 4 lines
As
dev_idsare only unique per PCI device, we would need a pointer to the "base" device. However, in the Broadcom 57712 case, there is no such "base" device. :-( So, usingdev_idhere doesn't seem like the right approach for these devices.
dev_ids can handle NPAR but I do understand that dev_id 0 is ambiguous. Two functions with dev_id 0 mean one thing for a driver that sets dev_id and a very different thing for one that doesn't.
Quoted 11 lines
What if we did something like this?
/sys/devices/net_ports/port0//sys/devices/pci0000:00/0000:00:1c.0/0000:0b:00.0/net/eth0/port ->/../../../../../net_ports/port0 /sys/devices/pci0000:00/0000:00:1c.0/0000:0b:00.1/net/eth1/port -> /../../../../../net_ports/port0In this case, the port0 "name" is simply a way to group interfaces into ports, it's not how ports are labeled on the chassis.
If I understand you right a "port" is a group of interfaces sharing one physical port without saying which one. I think dev_id does the same and specifies which physical port.
Quoted 4 lines
Do network drivers know how many ports they have?
What are the characteristics of network ports? Ideally, physical location (PCI slot), and index within that physical location.
This index is the dev_id for drivers that set it.
Quoted 11 lines
These
right now I'm deriving from SMBIOS and PCI, and if not explicitly exposed, counting devices on the same slot and assigning port numbers that way, but I would love to have explicit information from the drivers.Thoughts?
Thanks,
Matt
Quoted 44 lines · Dimitris Michailidis
Quoted 11 lines · Matt Domsch
Quoted 9 lines · Eilon Greenstein
Quoted 1 line · Dimitris Michailidis
Matt Domsch wrote:
...
Quoted 4 lines
/sys/class/net/<ifname>/dev_id indicates the physical port <ifname> is associated with. At least a few drivers set up
dev_idthis way.So we are on agreement? This can satisf all needs? If so, we will add this scheme to the bnx2x as well.
Quoted 6 lines
I don't think that's enough. Necessary, but not sufficient.
If
dev_idis a field that starts over with each PCI device (e.g. is used to distinguish multiple ports that share the same PCI device), that's enough to handle the Chelsio case, but not the NPAR & SR-IOV case.My understanding is that
dev_idindicates the physical port of the card associated with an interface. It does not reset when you move to a new function of the device.Quoted 6 lines
If the above is true, then a value of dev_id=0 for all 1:1 PCI Device : Port relations is fine, leaving the three drivers that set
dev_idnon-zero are all multi-port, single PCI device controllers.
cxgb4/t4_hw.c: adap->port[i]->dev_id = j;The HW cxgb4 deals with is multi-function (actually the driver uses primarily function 4 nowadays) but it's virtualizable and the association between functions and ports very flexible. For example, you may have a 2-port card but maybe the driver will be given just (a slice of) port 1. So the driver will create one netdev with dev_id==1 and there won't be anything with
dev_id0. You cannot determine this by looking at anything PCI-related or any static table.For this driver you can get two pieces of information for an interface:
- /sys/class/net/<interface>/device points to the PCI function handling the interface
- /sys/class/net/<interface>/dev_id indicates the physical port of the interface
Quoted 5 lines
You can have several interfaces with same device link and different
dev_id.
While the current driver doesn't do it you could also have several
interfaces with different device links but samedev_id(NPAR situation, notice again thatdev_idsare not per PCI function), or interfaces with different device anddev_id, or even interfaces with same device anddev_id.
What is the scope of dev_id then? It's not per PCI device like I thought. It sounds like it's per card, but how can I know the card boundary?
If I have 2 cards driven by cxgb4 in the system, each with say 4 ports. I could see a minimum of 8 PCI devices (fine), but the dev_id values would be? 0,1,2,3; 0,1,2,3 ? How can I tell that these are two different cards, with two different sets of dev_id values, rather than one card with 4 ports, 8 (NPAR or SR-IOV) interfaces, with each 2 interfaces mapping to the same port?
dev_id is not system-wide unique. It's not even slot unique best as I can tell. If I had a PCI slot extender, with 2 PCI slots, and I put two of the above cards in, I would see 0,1,2,3; 0,1,2,3. To be fair, my naming scheme doesn't really account for such an extender, though currently it would go pci<slot>#<12345678>.
Quoted 3 lines
dev_idscan handle NPAR but I do understand thatdev_id0 is ambiguous. Two functions withdev_id0 mean one thing for a driver that setsdev_idand a very different thing for one that doesn't.
yeah, that sucks.
Quoted 9 lines
Quoted 9 lines
What if we did something like this?
/sys/devices/net_ports/port0//sys/devices/pci0000:00/0000:00:1c.0/0000:0b:00.0/net/eth0/port ->
/../../../../../net_ports/port0
/sys/devices/pci0000:00/0000:00:1c.0/0000:0b:00.1/net/eth1/port ->
/../../../../../net_ports/port0
Quoted 6 lines
Quoted 2 lines
In this case, the port0 "name" is simply a way to group interfaces into ports, it's not how ports are labeled on the chassis.
If I understand you right a "port" is a group of interfaces sharing one physical port without saying which one. I think
dev_iddoes the same and specifies which physical port.
And I don't think it does, or at least, not in an unambiguous way, the dev_id=0 case and even != 0. Understanding the boundary of dev_id domains is the key, and I clearly don't.
Please advise.
Thanks,
Matt
Signature · 3 lines
Matt Domsch Technology Strategist Dell | Office of the CTO
Quoted 6 lines · Matt Domsch
Quoted 3 lines
You can have several interfaces with same device link and different
dev_id.
While the current driver doesn't do it you could also have several
interfaces with different device links but samedev_id(NPAR situation, notice again thatdev_idsare not per PCI function), or interfaces with different device anddev_id, or even interfaces with same device anddev_id.What is the scope of
dev_idthen? It's not per PCI device like I thought.
I don't think it could be that way because for these cards you can't statically tell which ports are controlled by a PCI function. So knowing that an interface is say port 0 of a function would help little.
Quoted 2 lines
It sounds like it's per card, but how can I know the card boundary?
Yes, it's per card and covers the PFs and VFs of the card.
Quoted 3 lines
If I have 2 cards driven by cxgb4 in the system, each with say 4 ports. I could see a minimum of 8 PCI devices (fine), but the
dev_idvalues would be? 0,1,2,3; 0,1,2,3 ?
Correct.
Quoted 4 lines
How can I tell that these are
two different cards, with two different sets ofdev_idvalues, rather than one card with 4 ports, 8 (NPAR or SR-IOV) interfaces, with each 2 interfaces mapping to the same port?
Doesn't the information in /sys/devices distinguish them? For example, something like
/sys/devices/pci0000:00/0000:00:07.0/0000:04:00.0/net/eth2/dev_id == 0 /sys/devices/pci0000:00/0000:00:07.0/0000:04:00.1/net/eth3/dev_id == 0 /sys/devices/pci0000:00/0000:00:07.0/0000:04:01.0/net/eth5/dev_id == 0 /sys/devices/pci0000:00/0000:00:1c.0/0000:05:00.0/net/eth4/dev_id == 0
tells me there are two cards, one has eth4 on port 0, the other has eth2, eth3, and eth5 on its port 0 with eth5 being on a VF.
Quoted 5 lines
dev_idis not system-wide unique. It's not even slot unique best as I can tell. If I had a PCI slot extender, with 2 PCI slots, and I put two of the above cards in, I would see 0,1,2,3; 0,1,2,3. To be fair, my naming scheme doesn't really account for such an extender, though currently it would go pci<slot>#<12345678>.
Can you give an example of what /sys/devices looks like in the case you're considering?
Quoted 41 lines · Dimitris Michailidis
Quoted 8 lines · Matt Domsch
Quoted 5 lines
You can have several interfaces with same device link and different
dev_id.
While the current driver doesn't do it you could also have several
interfaces with different device links but samedev_id(NPAR situation, notice again thatdev_idsare not per PCI function), or interfaces with different device anddev_id, or even interfaces with same device anddev_id.What is the scope of
dev_idthen? It's not per PCI device like I thought.I don't think it could be that way because for these cards you can't statically tell which ports are controlled by a PCI function. So knowing that an interface is say port 0 of a function would help little.
Quoted 2 lines
It sounds like it's per card, but how can I know the card boundary?
Yes, it's per card and covers the PFs and VFs of the card.
Quoted 3 lines
If I have 2 cards driven by cxgb4 in the system, each with say 4 ports. I could see a minimum of 8 PCI devices (fine), but the
dev_idvalues would be? 0,1,2,3; 0,1,2,3 ?Correct.
Quoted 4 lines
How can I tell that these are
two different cards, with two different sets ofdev_idvalues, rather than one card with 4 ports, 8 (NPAR or SR-IOV) interfaces, with each 2 interfaces mapping to the same port?Doesn't the information in
/sys/devicesdistinguish them? For example, something like/sys/devices/pci0000:00/0000:00:07.0/0000:04:00.0/net/eth2/dev_id == 0 /sys/devices/pci0000:00/0000:00:07.0/0000:04:00.1/net/eth3/dev_id == 0 /sys/devices/pci0000:00/0000:00:07.0/0000:04:01.0/net/eth5/dev_id == 0 /sys/devices/pci0000:00/0000:00:1c.0/0000:05:00.0/net/eth4/dev_id == 0
tells me there are two cards, one has eth4 on port 0, the other has eth2, eth3, and eth5 on its port 0 with eth5 being on a VF.
Quoted 8 lines
Quoted 5 lines
dev_idis not system-wide unique. It's not even slot unique best as I can tell. If I had a PCI slot extender, with 2 PCI slots, and I put two of the above cards in, I would see 0,1,2,3; 0,1,2,3. To be fair, my naming scheme doesn't really account for such an extender, though currently it would go pci<slot>#<12345678>.Can you give an example of what
/sys/deviceslooks like in the case you're considering?
Matt,
Happy New Year!
Does the dev_id approach suits your needs? Do you want to proceed in that direction?
Thanks,
Eilon
From: "Dmitry Kravkov" <[email protected]>
Date: Mon, 29 Nov 2010 00:09:37 +0200
Quoted 10 lines
NIC partitioning is another flavor of multi function - having few PCI functions share the same physical port. Unlike the currently supported mode of multi-function which depends on the switch configuration and uses outer-VLAN, the NPAR mode is switch independent and uses the MAC addresses to distribute incoming packets to the different functions. This patch adds the specific HW setting of the NPAR mode and some distinctions between switch dependent (SD) and
switch independent (SI) multi-function (MF) modes where the configuration is not the same.
Quoted 4 lines
Advance driver version to 1.60.00-6
Signed-off-by Dmitry Kravkov <[email protected]>Signed-off-by Eilon Greenstein <[email protected]>
Applied to net-next-2.6, but I expect you to keep discussing the naming and sysfs issues with Matt Domsch. :-)