Author: jhb
Date: Fri Aug 19 17:52:48 2016
New Revision: 304482
URL: https://svnweb.freebsd.org/changeset/base/304482

Log:
  Adjust t4_port_init() to work with VF devices.
  
  Specifically, the FW_PORT_CMD may or may not work for a VF (the PF
  driver can choose whether or not to permit access to this command),
  so don't attempt to fetch port information on a VF if permission is
  denied by the PF.
  
  Reviewed by:  np
  Sponsored by: Chelsio Communications
  Differential Revision:        https://reviews.freebsd.org/D7511

Modified:
  head/sys/dev/cxgbe/common/t4_hw.c

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==============================================================================
--- head/sys/dev/cxgbe/common/t4_hw.c   Fri Aug 19 17:51:52 2016        
(r304481)
+++ head/sys/dev/cxgbe/common/t4_hw.c   Fri Aug 19 17:52:48 2016        
(r304482)
@@ -7938,15 +7938,26 @@ int t4_port_init(struct adapter *adap, i
                } while ((adap->params.portvec & (1 << j)) == 0);
        }
 
-       c.op_to_portid = htonl(V_FW_CMD_OP(FW_PORT_CMD) |
-                              F_FW_CMD_REQUEST | F_FW_CMD_READ |
-                              V_FW_PORT_CMD_PORTID(j));
-       c.action_to_len16 = htonl(
-               V_FW_PORT_CMD_ACTION(FW_PORT_ACTION_GET_PORT_INFO) |
-               FW_LEN16(c));
-       ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
-       if (ret)
-               return ret;
+       if (!(adap->flags & IS_VF) ||
+           adap->params.vfres.r_caps & FW_CMD_CAP_PORT) {
+               c.op_to_portid = htonl(V_FW_CMD_OP(FW_PORT_CMD) |
+                                      F_FW_CMD_REQUEST | F_FW_CMD_READ |
+                                      V_FW_PORT_CMD_PORTID(j));
+               c.action_to_len16 = htonl(
+                       V_FW_PORT_CMD_ACTION(FW_PORT_ACTION_GET_PORT_INFO) |
+                       FW_LEN16(c));
+               ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
+               if (ret)
+                       return ret;
+
+               ret = be32_to_cpu(c.u.info.lstatus_to_modtype);
+               p->mdio_addr = (ret & F_FW_PORT_CMD_MDIOCAP) ?
+                       G_FW_PORT_CMD_MDIOADDR(ret) : -1;
+               p->port_type = G_FW_PORT_CMD_PTYPE(ret);
+               p->mod_type = G_FW_PORT_CMD_MODTYPE(ret);
+
+               init_link_config(&p->link_cfg, be16_to_cpu(c.u.info.pcap));
+       }
 
        ret = t4_alloc_vi(adap, mbox, j, pf, vf, 1, addr, &rss_size);
        if (ret < 0)
@@ -7959,14 +7970,6 @@ int t4_port_init(struct adapter *adap, i
        p->vi[0].rss_size = rss_size;
        t4_os_set_hw_addr(adap, p->port_id, addr);
 
-       ret = be32_to_cpu(c.u.info.lstatus_to_modtype);
-       p->mdio_addr = (ret & F_FW_PORT_CMD_MDIOCAP) ?
-               G_FW_PORT_CMD_MDIOADDR(ret) : -1;
-       p->port_type = G_FW_PORT_CMD_PTYPE(ret);
-       p->mod_type = G_FW_PORT_CMD_MODTYPE(ret);
-
-       init_link_config(&p->link_cfg, be16_to_cpu(c.u.info.pcap));
-
        param = V_FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) |
            V_FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_RSSINFO) |
            V_FW_PARAMS_PARAM_YZ(p->vi[0].viid);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to