Skip to content

Commit e6f6abe

Browse files
author
shurd
committed
bnxt: Add support for new phy_types and speeds - Part #2
Use our ifm_list of supported media types rather than nested switch statements to find the current media type. Find a supported type that matches the current speed. Remove all workarounds while updating ifmr->ifm_active. For BNXT_IFMEDIA_ADD, added Three more speeds IFM_10G_T, IFM_2500_T & IFM_2500_KX. Submitted by: Bhargava Chenna Marreddy <[email protected]> Reviewed by: shurd, sbruno Approved by: sbruno (mentor) Sponsored by: Broadcom Limited Differential Revision: https://reviews.freebsd.org/D12896 git-svn-id: svn+ssh://svn.freebsd.org/base/head@325488 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
1 parent f6931a7 commit e6f6abe

File tree

1 file changed

+15
-163
lines changed

1 file changed

+15
-163
lines changed

sys/dev/bnxt/if_bnxt.c

Lines changed: 15 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,10 @@ bnxt_media_status(if_ctx_t ctx, struct ifmediareq * ifmr)
11981198
{
11991199
struct bnxt_softc *softc = iflib_get_softc(ctx);
12001200
struct bnxt_link_info *link_info = &softc->link_info;
1201-
uint8_t phy_type = get_phy_type(softc);
1201+
struct ifmedia_entry *next;
1202+
uint64_t target_baudrate = bnxt_get_baudrate(link_info);
1203+
int active_media = IFM_UNKNOWN;
1204+
12021205

12031206
bnxt_update_link(softc, true);
12041207

@@ -1215,171 +1218,17 @@ bnxt_media_status(if_ctx_t ctx, struct ifmediareq * ifmr)
12151218
else
12161219
ifmr->ifm_active |= IFM_HDX;
12171220

1218-
switch (link_info->link_speed) {
1219-
case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB:
1220-
ifmr->ifm_active |= IFM_100_T;
1221-
break;
1222-
case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB:
1223-
switch (phy_type) {
1224-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX:
1225-
ifmr->ifm_active |= IFM_1000_KX;
1226-
break;
1227-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET:
1228-
ifmr->ifm_active |= IFM_1000_T;
1229-
break;
1230-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_SGMIIEXTPHY:
1231-
ifmr->ifm_active |= IFM_1000_SGMII;
1232-
break;
1233-
default:
1234-
/*
1235-
* Workaround:
1236-
* Don't return IFM_UNKNOWN until
1237-
* Stratus return proper media_type
1238-
*/
1239-
ifmr->ifm_active |= IFM_1000_KX;
1240-
break;
1241-
}
1242-
break;
1243-
case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2_5GB:
1244-
switch (phy_type) {
1245-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX:
1246-
ifmr->ifm_active |= IFM_2500_KX;
1247-
break;
1248-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET:
1249-
ifmr->ifm_active |= IFM_2500_T;
1250-
break;
1251-
default:
1252-
ifmr->ifm_active |= IFM_UNKNOWN;
1253-
break;
1254-
}
1255-
break;
1256-
case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB:
1257-
switch (phy_type) {
1258-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR:
1259-
ifmr->ifm_active |= IFM_10G_CR1;
1260-
break;
1261-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4:
1262-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2:
1263-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR:
1264-
ifmr->ifm_active |= IFM_10G_KR;
1265-
break;
1266-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASELR:
1267-
ifmr->ifm_active |= IFM_10G_LR;
1268-
break;
1269-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR:
1270-
ifmr->ifm_active |= IFM_10G_SR;
1271-
break;
1272-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX:
1273-
ifmr->ifm_active |= IFM_10G_KX4;
1274-
break;
1275-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET:
1276-
ifmr->ifm_active |= IFM_10G_T;
1277-
break;
1278-
default:
1279-
/*
1280-
* Workaround:
1281-
* Don't return IFM_UNKNOWN until
1282-
* Stratus return proper media_type
1283-
*/
1284-
ifmr->ifm_active |= IFM_10G_CR1;
1285-
break;
1286-
}
1287-
break;
1288-
case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB:
1289-
ifmr->ifm_active |= IFM_20G_KR2;
1290-
break;
1291-
case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_25GB:
1292-
switch (phy_type) {
1293-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR:
1294-
ifmr->ifm_active |= IFM_25G_CR;
1295-
break;
1296-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4:
1297-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2:
1298-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR:
1299-
ifmr->ifm_active |= IFM_25G_KR;
1300-
break;
1301-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR:
1302-
ifmr->ifm_active |= IFM_25G_SR;
1303-
break;
1304-
default:
1305-
/*
1306-
* Workaround:
1307-
* Don't return IFM_UNKNOWN until
1308-
* Stratus return proper media_type
1309-
*/
1310-
ifmr->ifm_active |= IFM_25G_CR;
1311-
break;
1312-
}
1313-
break;
1314-
case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB:
1315-
switch (phy_type) {
1316-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR:
1317-
ifmr->ifm_active |= IFM_40G_CR4;
1318-
break;
1319-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4:
1320-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2:
1321-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR:
1322-
ifmr->ifm_active |= IFM_40G_KR4;
1323-
break;
1324-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASELR:
1325-
ifmr->ifm_active |= IFM_40G_LR4;
1326-
break;
1327-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR:
1328-
ifmr->ifm_active |= IFM_40G_SR4;
1329-
break;
1330-
default:
1331-
ifmr->ifm_active |= IFM_UNKNOWN;
1332-
break;
1333-
}
1334-
break;
1335-
case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB:
1336-
switch (phy_type) {
1337-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR:
1338-
ifmr->ifm_active |= IFM_50G_CR2;
1339-
break;
1340-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4:
1341-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2:
1342-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR:
1343-
ifmr->ifm_active |= IFM_50G_KR2;
1344-
break;
1345-
default:
1346-
/*
1347-
* Workaround:
1348-
* Don't return IFM_UNKNOWN until
1349-
* Stratus return proper media_type
1350-
*/
1351-
ifmr->ifm_active |= IFM_50G_CR2;
1352-
break;
1353-
}
1354-
break;
1355-
case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100GB:
1356-
switch (phy_type) {
1357-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASECR:
1358-
ifmr->ifm_active |= IFM_100G_CR4;
1359-
break;
1360-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR4:
1361-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR2:
1362-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKR:
1363-
ifmr->ifm_active |= IFM_100G_KR4;
1364-
break;
1365-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASELR:
1366-
ifmr->ifm_active |= IFM_100G_LR4;
1367-
break;
1368-
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASESR:
1369-
ifmr->ifm_active |= IFM_100G_SR4;
1370-
break;
1371-
default:
1372-
/*
1373-
* Workaround:
1374-
* Don't return IFM_UNKNOWN until
1375-
* Stratus return proper media_type
1376-
*/
1377-
ifmr->ifm_active |= IFM_100G_CR4;
1221+
/*
1222+
* Go through the list of supported media which got prepared
1223+
* as part of bnxt_add_media_types() using api ifmedia_add().
1224+
*/
1225+
LIST_FOREACH(next, &(iflib_get_media(ctx)->ifm_list), ifm_list) {
1226+
if (ifmedia_baudrate(next->ifm_media) == target_baudrate) {
1227+
active_media = next->ifm_media;
13781228
break;
13791229
}
1380-
default:
1381-
return;
13821230
}
1231+
ifmr->ifm_active |= active_media;
13831232

13841233
if (link_info->flow_ctrl.rx)
13851234
ifmr->ifm_active |= IFM_ETH_RXPAUSE;
@@ -2184,13 +2033,16 @@ bnxt_add_media_types(struct bnxt_softc *softc)
21842033
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_1G_BASET:
21852034
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASET:
21862035
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASETE:
2036+
BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_T);
2037+
BNXT_IFMEDIA_ADD(supported, SPEEDS_2_5GB, IFM_2500_T);
21872038
BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_T);
21882039
BNXT_IFMEDIA_ADD(supported, SPEEDS_100MB, IFM_100_T);
21892040
BNXT_IFMEDIA_ADD(supported, SPEEDS_10MB, IFM_10_T);
21902041
break;
21912042

21922043
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_BASEKX:
21932044
BNXT_IFMEDIA_ADD(supported, SPEEDS_10GB, IFM_10G_KR);
2045+
BNXT_IFMEDIA_ADD(supported, SPEEDS_2_5GB, IFM_2500_KX);
21942046
BNXT_IFMEDIA_ADD(supported, SPEEDS_1GB, IFM_1000_KX);
21952047
break;
21962048

0 commit comments

Comments
 (0)