]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
qed: Support dcbnl IEEE selector field.
authorsudarsana.kalluru@cavium.com <sudarsana.kalluru@cavium.com>
Fri, 21 Apr 2017 05:31:19 +0000 (22:31 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Apr 2017 16:19:55 +0000 (12:19 -0400)
Signed-off-by: Sudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qed/qed_dcbx.c
drivers/net/ethernet/qlogic/qede/qede_dcbnl.c

index 46865a582eb43af8493cb36da541e2391ac84e68..40a4975443e42fe178c9413185259a5a50f6e467 100644 (file)
@@ -2192,15 +2192,46 @@ qed_dcbnl_ieee_peer_getpfc(struct qed_dev *cdev, struct ieee_pfc *pfc)
        return qed_dcbnl_get_ieee_pfc(cdev, pfc, true);
 }
 
+static int qed_get_sf_ieee_value(u8 selector, u8 *sf_ieee)
+{
+       switch (selector) {
+       case IEEE_8021QAZ_APP_SEL_ETHERTYPE:
+               *sf_ieee = QED_DCBX_SF_IEEE_ETHTYPE;
+               break;
+       case IEEE_8021QAZ_APP_SEL_STREAM:
+               *sf_ieee = QED_DCBX_SF_IEEE_TCP_PORT;
+               break;
+       case IEEE_8021QAZ_APP_SEL_DGRAM:
+               *sf_ieee = QED_DCBX_SF_IEEE_UDP_PORT;
+               break;
+       case IEEE_8021QAZ_APP_SEL_ANY:
+               *sf_ieee = QED_DCBX_SF_IEEE_TCP_UDP_PORT;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 static int qed_dcbnl_ieee_getapp(struct qed_dev *cdev, struct dcb_app *app)
 {
        struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
        struct qed_dcbx_get *dcbx_info;
        struct qed_app_entry *entry;
-       bool ethtype;
        u8 prio = 0;
+       u8 sf_ieee;
        int i;
 
+       DP_VERBOSE(hwfn, QED_MSG_DCB, "selector = %d protocol = %d\n",
+                  app->selector, app->protocol);
+
+       if (qed_get_sf_ieee_value(app->selector, &sf_ieee)) {
+               DP_INFO(cdev, "Invalid selector field value %d\n",
+                       app->selector);
+               return -EINVAL;
+       }
+
        dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
        if (!dcbx_info)
                return -EINVAL;
@@ -2211,11 +2242,9 @@ static int qed_dcbnl_ieee_getapp(struct qed_dev *cdev, struct dcb_app *app)
                return -EINVAL;
        }
 
-       /* ieee defines the selector field value for ethertype to be 1 */
-       ethtype = !!((app->selector - 1) == DCB_APP_IDTYPE_ETHTYPE);
        for (i = 0; i < QED_DCBX_MAX_APP_PROTOCOL; i++) {
                entry = &dcbx_info->operational.params.app_entry[i];
-               if ((entry->ethtype == ethtype) &&
+               if ((entry->sf_ieee == sf_ieee) &&
                    (entry->proto_id == app->protocol)) {
                        prio = entry->prio;
                        break;
@@ -2243,14 +2272,22 @@ static int qed_dcbnl_ieee_setapp(struct qed_dev *cdev, struct dcb_app *app)
        struct qed_dcbx_set dcbx_set;
        struct qed_app_entry *entry;
        struct qed_ptt *ptt;
-       bool ethtype;
+       u8 sf_ieee;
        int rc, i;
 
+       DP_VERBOSE(hwfn, QED_MSG_DCB, "selector = %d protocol = %d pri = %d\n",
+                  app->selector, app->protocol, app->priority);
        if (app->priority < 0 || app->priority >= QED_MAX_PFC_PRIORITIES) {
                DP_INFO(hwfn, "Invalid priority %d\n", app->priority);
                return -EINVAL;
        }
 
+       if (qed_get_sf_ieee_value(app->selector, &sf_ieee)) {
+               DP_INFO(cdev, "Invalid selector field value %d\n",
+                       app->selector);
+               return -EINVAL;
+       }
+
        dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
        if (!dcbx_info)
                return -EINVAL;
@@ -2268,11 +2305,9 @@ static int qed_dcbnl_ieee_setapp(struct qed_dev *cdev, struct dcb_app *app)
        if (rc)
                return -EINVAL;
 
-       /* ieee defines the selector field value for ethertype to be 1 */
-       ethtype = !!((app->selector - 1) == DCB_APP_IDTYPE_ETHTYPE);
        for (i = 0; i < QED_DCBX_MAX_APP_PROTOCOL; i++) {
                entry = &dcbx_set.config.params.app_entry[i];
-               if ((entry->ethtype == ethtype) &&
+               if ((entry->sf_ieee == sf_ieee) &&
                    (entry->proto_id == app->protocol))
                        break;
                /* First empty slot */
@@ -2288,7 +2323,7 @@ static int qed_dcbnl_ieee_setapp(struct qed_dev *cdev, struct dcb_app *app)
        }
 
        dcbx_set.override_flags |= QED_DCBX_OVERRIDE_APP_CFG;
-       dcbx_set.config.params.app_entry[i].ethtype = ethtype;
+       dcbx_set.config.params.app_entry[i].sf_ieee = sf_ieee;
        dcbx_set.config.params.app_entry[i].proto_id = app->protocol;
        dcbx_set.config.params.app_entry[i].prio = BIT(app->priority);
 
index 03e8c021243339eb78e3891cc81b4ba7cb582453..a9e7379313db7bdff8032605f2811c3d210c2152 100644 (file)
@@ -281,6 +281,11 @@ static int qede_dcbnl_ieee_setapp(struct net_device *netdev,
                                  struct dcb_app *app)
 {
        struct qede_dev *edev = netdev_priv(netdev);
+       int err;
+
+       err = dcb_ieee_setapp(netdev, app);
+       if (err)
+               return err;
 
        return edev->ops->dcb->ieee_setapp(edev->cdev, app);
 }