Skip to content

Commit 96fe11f

Browse files
Ganesh Goudardavem330
authored andcommitted
cxgb4: Implement ndo_get_phys_port_id for mgmt dev
Signed-off-by: Ganesh Goudar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a7ef671 commit 96fe11f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,6 +2583,19 @@ static int cxgb_get_vf_config(struct net_device *dev,
25832583
ether_addr_copy(ivi->mac, adap->vfinfo[vf].vf_mac_addr);
25842584
return 0;
25852585
}
2586+
2587+
static int cxgb_get_phys_port_id(struct net_device *dev,
2588+
struct netdev_phys_item_id *ppid)
2589+
{
2590+
struct port_info *pi = netdev_priv(dev);
2591+
unsigned int phy_port_id;
2592+
2593+
phy_port_id = pi->adapter->adap_idx * 10 + pi->port_id;
2594+
ppid->id_len = sizeof(phy_port_id);
2595+
memcpy(ppid->id, &phy_port_id, ppid->id_len);
2596+
return 0;
2597+
}
2598+
25862599
#endif
25872600

25882601
static int cxgb_set_mac_addr(struct net_device *dev, void *p)
@@ -2762,6 +2775,7 @@ static const struct net_device_ops cxgb4_mgmt_netdev_ops = {
27622775
.ndo_open = dummy_open,
27632776
.ndo_set_vf_mac = cxgb_set_vf_mac,
27642777
.ndo_get_vf_config = cxgb_get_vf_config,
2778+
.ndo_get_phys_port_id = cxgb_get_phys_port_id,
27652779
};
27662780
#endif
27672781

@@ -4539,6 +4553,7 @@ static int config_mgmt_dev(struct pci_dev *pdev)
45394553

45404554
pi = netdev_priv(netdev);
45414555
pi->adapter = adap;
4556+
pi->port_id = adap->pf % adap->params.nports;
45424557
SET_NETDEV_DEV(netdev, &pdev->dev);
45434558

45444559
adap->port[0] = netdev;
@@ -4628,6 +4643,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
46284643
u32 whoami, pl_rev;
46294644
enum chip_type chip;
46304645
static int adap_idx = 1;
4646+
u32 v, port_vec;
46314647

46324648
printk_once(KERN_INFO "%s - version %s\n", DRV_DESC, DRV_VERSION);
46334649

@@ -5009,6 +5025,17 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
50095025
}
50105026
spin_lock_init(&adapter->mbox_lock);
50115027
INIT_LIST_HEAD(&adapter->mlist.list);
5028+
5029+
v = FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
5030+
FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_PORTVEC);
5031+
err = t4_query_params(adapter, adapter->mbox, adapter->pf, 0, 1,
5032+
&v, &port_vec);
5033+
if (err < 0) {
5034+
dev_err(adapter->pdev_dev, "Could not fetch port params\n");
5035+
goto free_adapter;
5036+
}
5037+
5038+
adapter->params.nports = hweight32(port_vec);
50125039
pci_set_drvdata(pdev, adapter);
50135040
return 0;
50145041

0 commit comments

Comments
 (0)