Skip to content

Commit 05a79f9

Browse files
sudarsana.kalluru@cavium.comdavem330
authored andcommitted
qed: Support dcbnl IEEE selector field.
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>
1 parent dfbeb85 commit 05a79f9

File tree

2 files changed

+49
-9
lines changed

2 files changed

+49
-9
lines changed

drivers/net/ethernet/qlogic/qed/qed_dcbx.c

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,15 +2192,46 @@ qed_dcbnl_ieee_peer_getpfc(struct qed_dev *cdev, struct ieee_pfc *pfc)
21922192
return qed_dcbnl_get_ieee_pfc(cdev, pfc, true);
21932193
}
21942194

2195+
static int qed_get_sf_ieee_value(u8 selector, u8 *sf_ieee)
2196+
{
2197+
switch (selector) {
2198+
case IEEE_8021QAZ_APP_SEL_ETHERTYPE:
2199+
*sf_ieee = QED_DCBX_SF_IEEE_ETHTYPE;
2200+
break;
2201+
case IEEE_8021QAZ_APP_SEL_STREAM:
2202+
*sf_ieee = QED_DCBX_SF_IEEE_TCP_PORT;
2203+
break;
2204+
case IEEE_8021QAZ_APP_SEL_DGRAM:
2205+
*sf_ieee = QED_DCBX_SF_IEEE_UDP_PORT;
2206+
break;
2207+
case IEEE_8021QAZ_APP_SEL_ANY:
2208+
*sf_ieee = QED_DCBX_SF_IEEE_TCP_UDP_PORT;
2209+
break;
2210+
default:
2211+
return -EINVAL;
2212+
}
2213+
2214+
return 0;
2215+
}
2216+
21952217
static int qed_dcbnl_ieee_getapp(struct qed_dev *cdev, struct dcb_app *app)
21962218
{
21972219
struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
21982220
struct qed_dcbx_get *dcbx_info;
21992221
struct qed_app_entry *entry;
2200-
bool ethtype;
22012222
u8 prio = 0;
2223+
u8 sf_ieee;
22022224
int i;
22032225

2226+
DP_VERBOSE(hwfn, QED_MSG_DCB, "selector = %d protocol = %d\n",
2227+
app->selector, app->protocol);
2228+
2229+
if (qed_get_sf_ieee_value(app->selector, &sf_ieee)) {
2230+
DP_INFO(cdev, "Invalid selector field value %d\n",
2231+
app->selector);
2232+
return -EINVAL;
2233+
}
2234+
22042235
dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
22052236
if (!dcbx_info)
22062237
return -EINVAL;
@@ -2211,11 +2242,9 @@ static int qed_dcbnl_ieee_getapp(struct qed_dev *cdev, struct dcb_app *app)
22112242
return -EINVAL;
22122243
}
22132244

2214-
/* ieee defines the selector field value for ethertype to be 1 */
2215-
ethtype = !!((app->selector - 1) == DCB_APP_IDTYPE_ETHTYPE);
22162245
for (i = 0; i < QED_DCBX_MAX_APP_PROTOCOL; i++) {
22172246
entry = &dcbx_info->operational.params.app_entry[i];
2218-
if ((entry->ethtype == ethtype) &&
2247+
if ((entry->sf_ieee == sf_ieee) &&
22192248
(entry->proto_id == app->protocol)) {
22202249
prio = entry->prio;
22212250
break;
@@ -2243,14 +2272,22 @@ static int qed_dcbnl_ieee_setapp(struct qed_dev *cdev, struct dcb_app *app)
22432272
struct qed_dcbx_set dcbx_set;
22442273
struct qed_app_entry *entry;
22452274
struct qed_ptt *ptt;
2246-
bool ethtype;
2275+
u8 sf_ieee;
22472276
int rc, i;
22482277

2278+
DP_VERBOSE(hwfn, QED_MSG_DCB, "selector = %d protocol = %d pri = %d\n",
2279+
app->selector, app->protocol, app->priority);
22492280
if (app->priority < 0 || app->priority >= QED_MAX_PFC_PRIORITIES) {
22502281
DP_INFO(hwfn, "Invalid priority %d\n", app->priority);
22512282
return -EINVAL;
22522283
}
22532284

2285+
if (qed_get_sf_ieee_value(app->selector, &sf_ieee)) {
2286+
DP_INFO(cdev, "Invalid selector field value %d\n",
2287+
app->selector);
2288+
return -EINVAL;
2289+
}
2290+
22542291
dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
22552292
if (!dcbx_info)
22562293
return -EINVAL;
@@ -2268,11 +2305,9 @@ static int qed_dcbnl_ieee_setapp(struct qed_dev *cdev, struct dcb_app *app)
22682305
if (rc)
22692306
return -EINVAL;
22702307

2271-
/* ieee defines the selector field value for ethertype to be 1 */
2272-
ethtype = !!((app->selector - 1) == DCB_APP_IDTYPE_ETHTYPE);
22732308
for (i = 0; i < QED_DCBX_MAX_APP_PROTOCOL; i++) {
22742309
entry = &dcbx_set.config.params.app_entry[i];
2275-
if ((entry->ethtype == ethtype) &&
2310+
if ((entry->sf_ieee == sf_ieee) &&
22762311
(entry->proto_id == app->protocol))
22772312
break;
22782313
/* First empty slot */
@@ -2288,7 +2323,7 @@ static int qed_dcbnl_ieee_setapp(struct qed_dev *cdev, struct dcb_app *app)
22882323
}
22892324

22902325
dcbx_set.override_flags |= QED_DCBX_OVERRIDE_APP_CFG;
2291-
dcbx_set.config.params.app_entry[i].ethtype = ethtype;
2326+
dcbx_set.config.params.app_entry[i].sf_ieee = sf_ieee;
22922327
dcbx_set.config.params.app_entry[i].proto_id = app->protocol;
22932328
dcbx_set.config.params.app_entry[i].prio = BIT(app->priority);
22942329

drivers/net/ethernet/qlogic/qede/qede_dcbnl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ static int qede_dcbnl_ieee_setapp(struct net_device *netdev,
281281
struct dcb_app *app)
282282
{
283283
struct qede_dev *edev = netdev_priv(netdev);
284+
int err;
285+
286+
err = dcb_ieee_setapp(netdev, app);
287+
if (err)
288+
return err;
284289

285290
return edev->ops->dcb->ieee_setapp(edev->cdev, app);
286291
}

0 commit comments

Comments
 (0)