Skip to content

Commit e40a826

Browse files
Sudarsana Reddy Kallurudavem330
authored andcommitted
qed: Add support for virtual link.
Currently driver registers to physical link notifications (of the device) from Management firmware (MFW). Driver doesn't get notified if there's a change in the virtual link e.g., link-flap on the peer PF interface. Virtual link indication from MFW reflects the per PF link status instead of the physical link. The patch adds driver support for, - Advertising the virtual link support to MFW. - Handling the virtual link notification from MFW. Please consider applying it to 'net-next'. Signed-off-by: Sudarsana Reddy Kalluru <[email protected]> Signed-off-by: Tomer Tayar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b187191 commit e40a826

File tree

2 files changed

+73
-52
lines changed

2 files changed

+73
-52
lines changed

drivers/net/ethernet/qlogic/qed/qed_hsi.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12276,7 +12276,7 @@ struct public_func {
1227612276
#define FUNC_MF_CFG_MAX_BW_DEFAULT 0x00640000
1227712277

1227812278
u32 status;
12279-
#define FUNC_STATUS_VLINK_DOWN 0x00000001
12279+
#define FUNC_STATUS_VIRTUAL_LINK_UP 0x00000001
1228012280

1228112281
u32 mac_upper;
1228212282
#define FUNC_MF_CFG_UPPERMAC_MASK 0x0000ffff
@@ -12698,6 +12698,7 @@ struct public_drv_mb {
1269812698
#define DRV_MB_PARAM_FEATURE_SUPPORT_PORT_MASK 0x0000FFFF
1269912699
#define DRV_MB_PARAM_FEATURE_SUPPORT_PORT_OFFSET 0
1270012700
#define DRV_MB_PARAM_FEATURE_SUPPORT_PORT_EEE 0x00000002
12701+
#define DRV_MB_PARAM_FEATURE_SUPPORT_FUNC_VLINK 0x00010000
1270112702

1270212703
u32 fw_mb_header;
1270312704
#define FW_MSG_CODE_MASK 0xffff0000
@@ -12750,6 +12751,7 @@ struct public_drv_mb {
1275012751

1275112752
/* get MFW feature support response */
1275212753
#define FW_MB_PARAM_FEATURE_SUPPORT_EEE 0x00000002
12754+
#define FW_MB_PARAM_FEATURE_SUPPORT_VLINK 0x00010000
1275312755

1275412756
#define FW_MB_PARAM_LOAD_DONE_DID_EFUSE_ERROR (1 << 0)
1275512757

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

Lines changed: 70 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,52 @@ static void qed_mcp_read_eee_config(struct qed_hwfn *p_hwfn,
12471247
p_link->eee_lp_adv_caps |= QED_EEE_10G_ADV;
12481248
}
12491249

1250+
static u32 qed_mcp_get_shmem_func(struct qed_hwfn *p_hwfn,
1251+
struct qed_ptt *p_ptt,
1252+
struct public_func *p_data, int pfid)
1253+
{
1254+
u32 addr = SECTION_OFFSIZE_ADDR(p_hwfn->mcp_info->public_base,
1255+
PUBLIC_FUNC);
1256+
u32 mfw_path_offsize = qed_rd(p_hwfn, p_ptt, addr);
1257+
u32 func_addr;
1258+
u32 i, size;
1259+
1260+
func_addr = SECTION_ADDR(mfw_path_offsize, pfid);
1261+
memset(p_data, 0, sizeof(*p_data));
1262+
1263+
size = min_t(u32, sizeof(*p_data), QED_SECTION_SIZE(mfw_path_offsize));
1264+
for (i = 0; i < size / sizeof(u32); i++)
1265+
((u32 *)p_data)[i] = qed_rd(p_hwfn, p_ptt,
1266+
func_addr + (i << 2));
1267+
return size;
1268+
}
1269+
1270+
static void qed_read_pf_bandwidth(struct qed_hwfn *p_hwfn,
1271+
struct public_func *p_shmem_info)
1272+
{
1273+
struct qed_mcp_function_info *p_info;
1274+
1275+
p_info = &p_hwfn->mcp_info->func_info;
1276+
1277+
p_info->bandwidth_min = QED_MFW_GET_FIELD(p_shmem_info->config,
1278+
FUNC_MF_CFG_MIN_BW);
1279+
if (p_info->bandwidth_min < 1 || p_info->bandwidth_min > 100) {
1280+
DP_INFO(p_hwfn,
1281+
"bandwidth minimum out of bounds [%02x]. Set to 1\n",
1282+
p_info->bandwidth_min);
1283+
p_info->bandwidth_min = 1;
1284+
}
1285+
1286+
p_info->bandwidth_max = QED_MFW_GET_FIELD(p_shmem_info->config,
1287+
FUNC_MF_CFG_MAX_BW);
1288+
if (p_info->bandwidth_max < 1 || p_info->bandwidth_max > 100) {
1289+
DP_INFO(p_hwfn,
1290+
"bandwidth maximum out of bounds [%02x]. Set to 100\n",
1291+
p_info->bandwidth_max);
1292+
p_info->bandwidth_max = 100;
1293+
}
1294+
}
1295+
12501296
static void qed_mcp_handle_link_change(struct qed_hwfn *p_hwfn,
12511297
struct qed_ptt *p_ptt, bool b_reset)
12521298
{
@@ -1274,10 +1320,29 @@ static void qed_mcp_handle_link_change(struct qed_hwfn *p_hwfn,
12741320
goto out;
12751321
}
12761322

1277-
if (p_hwfn->b_drv_link_init)
1278-
p_link->link_up = !!(status & LINK_STATUS_LINK_UP);
1279-
else
1323+
if (p_hwfn->b_drv_link_init) {
1324+
/* Link indication with modern MFW arrives as per-PF
1325+
* indication.
1326+
*/
1327+
if (p_hwfn->mcp_info->capabilities &
1328+
FW_MB_PARAM_FEATURE_SUPPORT_VLINK) {
1329+
struct public_func shmem_info;
1330+
1331+
qed_mcp_get_shmem_func(p_hwfn, p_ptt, &shmem_info,
1332+
MCP_PF_ID(p_hwfn));
1333+
p_link->link_up = !!(shmem_info.status &
1334+
FUNC_STATUS_VIRTUAL_LINK_UP);
1335+
qed_read_pf_bandwidth(p_hwfn, &shmem_info);
1336+
DP_VERBOSE(p_hwfn, NETIF_MSG_LINK,
1337+
"Virtual link_up = %d\n", p_link->link_up);
1338+
} else {
1339+
p_link->link_up = !!(status & LINK_STATUS_LINK_UP);
1340+
DP_VERBOSE(p_hwfn, NETIF_MSG_LINK,
1341+
"Physical link_up = %d\n", p_link->link_up);
1342+
}
1343+
} else {
12801344
p_link->link_up = false;
1345+
}
12811346

12821347
p_link->full_duplex = true;
12831348
switch ((status & LINK_STATUS_SPEED_AND_DUPLEX_MASK)) {
@@ -1504,53 +1569,6 @@ static void qed_mcp_send_protocol_stats(struct qed_hwfn *p_hwfn,
15041569
qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params);
15051570
}
15061571

1507-
static void qed_read_pf_bandwidth(struct qed_hwfn *p_hwfn,
1508-
struct public_func *p_shmem_info)
1509-
{
1510-
struct qed_mcp_function_info *p_info;
1511-
1512-
p_info = &p_hwfn->mcp_info->func_info;
1513-
1514-
p_info->bandwidth_min = (p_shmem_info->config &
1515-
FUNC_MF_CFG_MIN_BW_MASK) >>
1516-
FUNC_MF_CFG_MIN_BW_SHIFT;
1517-
if (p_info->bandwidth_min < 1 || p_info->bandwidth_min > 100) {
1518-
DP_INFO(p_hwfn,
1519-
"bandwidth minimum out of bounds [%02x]. Set to 1\n",
1520-
p_info->bandwidth_min);
1521-
p_info->bandwidth_min = 1;
1522-
}
1523-
1524-
p_info->bandwidth_max = (p_shmem_info->config &
1525-
FUNC_MF_CFG_MAX_BW_MASK) >>
1526-
FUNC_MF_CFG_MAX_BW_SHIFT;
1527-
if (p_info->bandwidth_max < 1 || p_info->bandwidth_max > 100) {
1528-
DP_INFO(p_hwfn,
1529-
"bandwidth maximum out of bounds [%02x]. Set to 100\n",
1530-
p_info->bandwidth_max);
1531-
p_info->bandwidth_max = 100;
1532-
}
1533-
}
1534-
1535-
static u32 qed_mcp_get_shmem_func(struct qed_hwfn *p_hwfn,
1536-
struct qed_ptt *p_ptt,
1537-
struct public_func *p_data, int pfid)
1538-
{
1539-
u32 addr = SECTION_OFFSIZE_ADDR(p_hwfn->mcp_info->public_base,
1540-
PUBLIC_FUNC);
1541-
u32 mfw_path_offsize = qed_rd(p_hwfn, p_ptt, addr);
1542-
u32 func_addr = SECTION_ADDR(mfw_path_offsize, pfid);
1543-
u32 i, size;
1544-
1545-
memset(p_data, 0, sizeof(*p_data));
1546-
1547-
size = min_t(u32, sizeof(*p_data), QED_SECTION_SIZE(mfw_path_offsize));
1548-
for (i = 0; i < size / sizeof(u32); i++)
1549-
((u32 *)p_data)[i] = qed_rd(p_hwfn, p_ptt,
1550-
func_addr + (i << 2));
1551-
return size;
1552-
}
1553-
15541572
static void qed_mcp_update_bw(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
15551573
{
15561574
struct qed_mcp_function_info *p_info;
@@ -3351,7 +3369,8 @@ int qed_mcp_set_capabilities(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
33513369
{
33523370
u32 mcp_resp, mcp_param, features;
33533371

3354-
features = DRV_MB_PARAM_FEATURE_SUPPORT_PORT_EEE;
3372+
features = DRV_MB_PARAM_FEATURE_SUPPORT_PORT_EEE |
3373+
DRV_MB_PARAM_FEATURE_SUPPORT_FUNC_VLINK;
33553374

33563375
return qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_FEATURE_SUPPORT,
33573376
features, &mcp_resp, &mcp_param);

0 commit comments

Comments
 (0)