@@ -2916,6 +2916,39 @@ static const struct net_device_ops cxgb4vf_netdev_ops = {
29162916#endif
29172917};
29182918
2919+ /**
2920+ * cxgb4vf_get_port_mask - Get port mask for the VF based on mac
2921+ * address stored on the adapter
2922+ * @adapter: The adapter
2923+ *
2924+ * Find the the port mask for the VF based on the index of mac
2925+ * address stored in the adapter. If no mac address is stored on
2926+ * the adapter for the VF, use the port mask received from the
2927+ * firmware.
2928+ */
2929+ static unsigned int cxgb4vf_get_port_mask (struct adapter * adapter )
2930+ {
2931+ unsigned int naddr = 1 , pidx = 0 ;
2932+ unsigned int pmask , rmask = 0 ;
2933+ u8 mac [ETH_ALEN ];
2934+ int err ;
2935+
2936+ pmask = adapter -> params .vfres .pmask ;
2937+ while (pmask ) {
2938+ if (pmask & 1 ) {
2939+ err = t4vf_get_vf_mac_acl (adapter , pidx , & naddr , mac );
2940+ if (!err && !is_zero_ether_addr (mac ))
2941+ rmask |= (1 << pidx );
2942+ }
2943+ pmask >>= 1 ;
2944+ pidx ++ ;
2945+ }
2946+ if (!rmask )
2947+ rmask = adapter -> params .vfres .pmask ;
2948+
2949+ return rmask ;
2950+ }
2951+
29192952/*
29202953 * "Probe" a device: initialize a device and construct all kernel and driver
29212954 * state needed to manage the device. This routine is called "init_one" in
@@ -2924,13 +2957,12 @@ static const struct net_device_ops cxgb4vf_netdev_ops = {
29242957static int cxgb4vf_pci_probe (struct pci_dev * pdev ,
29252958 const struct pci_device_id * ent )
29262959{
2927- int pci_using_dac ;
2928- int err , pidx ;
2929- unsigned int pmask ;
29302960 struct adapter * adapter ;
2931- struct port_info * pi ;
29322961 struct net_device * netdev ;
2933- unsigned int pf ;
2962+ struct port_info * pi ;
2963+ unsigned int pmask ;
2964+ int pci_using_dac ;
2965+ int err , pidx ;
29342966
29352967 /*
29362968 * Initialize generic PCI device state.
@@ -3073,8 +3105,7 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
30733105 /*
30743106 * Allocate our "adapter ports" and stitch everything together.
30753107 */
3076- pmask = adapter -> params .vfres .pmask ;
3077- pf = t4vf_get_pf_from_vf (adapter );
3108+ pmask = cxgb4vf_get_port_mask (adapter );
30783109 for_each_port (adapter , pidx ) {
30793110 int port_id , viid ;
30803111 u8 mac [ETH_ALEN ];
@@ -3157,7 +3188,7 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
31573188 goto err_free_dev ;
31583189 }
31593190
3160- err = t4vf_get_vf_mac_acl (adapter , pf , & naddr , mac );
3191+ err = t4vf_get_vf_mac_acl (adapter , port_id , & naddr , mac );
31613192 if (err ) {
31623193 dev_err (& pdev -> dev ,
31633194 "unable to determine MAC ACL address, "
0 commit comments