Skip to content

Commit 5702b81

Browse files
committed
Merge branch 'ncsi-phy-link-up'
Ivan Mikhaylov says: ==================== net/ncsi: Add NCSI Intel OEM command to keep PHY link up Add NCSI Intel OEM command to keep PHY link up and prevents any channel resets during the host load on i210. Also includes dummy response handler for Intel manufacturer id. Changes from v1: 1. sparse fixes about casts 2. put it after ncsi_dev_state_probe_cis instead of ncsi_dev_state_probe_channel because sometimes channel is not ready after it 3. inl -> intel ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 96248d6 + 163f5de commit 5702b81

File tree

4 files changed

+68
-5
lines changed

4 files changed

+68
-5
lines changed

net/ncsi/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ config NCSI_OEM_CMD_GET_MAC
1717
help
1818
This allows to get MAC address from NCSI firmware and set them back to
1919
controller.
20+
config NCSI_OEM_CMD_KEEP_PHY
21+
bool "Keep PHY Link up"
22+
depends on NET_NCSI
23+
help
24+
This allows to keep PHY link up and prevents any channel resets during
25+
the host load.

net/ncsi/internal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ enum {
7878
/* OEM Vendor Manufacture ID */
7979
#define NCSI_OEM_MFR_MLX_ID 0x8119
8080
#define NCSI_OEM_MFR_BCM_ID 0x113d
81+
#define NCSI_OEM_MFR_INTEL_ID 0x157
82+
/* Intel specific OEM command */
83+
#define NCSI_OEM_INTEL_CMD_KEEP_PHY 0x20 /* CMD ID for Keep PHY up */
8184
/* Broadcom specific OEM Command */
8285
#define NCSI_OEM_BCM_CMD_GMA 0x01 /* CMD ID for Get MAC */
8386
/* Mellanox specific OEM Command */
@@ -86,6 +89,7 @@ enum {
8689
#define NCSI_OEM_MLX_CMD_SMAF 0x01 /* CMD ID for Set MC Affinity */
8790
#define NCSI_OEM_MLX_CMD_SMAF_PARAM 0x07 /* Parameter for SMAF */
8891
/* OEM Command payload lengths*/
92+
#define NCSI_OEM_INTEL_CMD_KEEP_PHY_LEN 7
8993
#define NCSI_OEM_BCM_CMD_GMA_LEN 12
9094
#define NCSI_OEM_MLX_CMD_GMA_LEN 8
9195
#define NCSI_OEM_MLX_CMD_SMAF_LEN 60
@@ -271,6 +275,7 @@ enum {
271275
ncsi_dev_state_probe_mlx_gma,
272276
ncsi_dev_state_probe_mlx_smaf,
273277
ncsi_dev_state_probe_cis,
278+
ncsi_dev_state_probe_keep_phy,
274279
ncsi_dev_state_probe_gvi,
275280
ncsi_dev_state_probe_gc,
276281
ncsi_dev_state_probe_gls,

net/ncsi/ncsi-manage.c

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,35 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc,
689689
return 0;
690690
}
691691

692+
#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY)
693+
694+
static int ncsi_oem_keep_phy_intel(struct ncsi_cmd_arg *nca)
695+
{
696+
unsigned char data[NCSI_OEM_INTEL_CMD_KEEP_PHY_LEN];
697+
int ret = 0;
698+
699+
nca->payload = NCSI_OEM_INTEL_CMD_KEEP_PHY_LEN;
700+
701+
memset(data, 0, NCSI_OEM_INTEL_CMD_KEEP_PHY_LEN);
702+
*(unsigned int *)data = ntohl((__force __be32)NCSI_OEM_MFR_INTEL_ID);
703+
704+
data[4] = NCSI_OEM_INTEL_CMD_KEEP_PHY;
705+
706+
/* PHY Link up attribute */
707+
data[6] = 0x1;
708+
709+
nca->data = data;
710+
711+
ret = ncsi_xmit_cmd(nca);
712+
if (ret)
713+
netdev_err(nca->ndp->ndev.dev,
714+
"NCSI: Failed to transmit cmd 0x%x during configure\n",
715+
nca->type);
716+
return ret;
717+
}
718+
719+
#endif
720+
692721
#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC)
693722

694723
/* NCSI OEM Command APIs */
@@ -700,7 +729,7 @@ static int ncsi_oem_gma_handler_bcm(struct ncsi_cmd_arg *nca)
700729
nca->payload = NCSI_OEM_BCM_CMD_GMA_LEN;
701730

702731
memset(data, 0, NCSI_OEM_BCM_CMD_GMA_LEN);
703-
*(unsigned int *)data = ntohl(NCSI_OEM_MFR_BCM_ID);
732+
*(unsigned int *)data = ntohl((__force __be32)NCSI_OEM_MFR_BCM_ID);
704733
data[5] = NCSI_OEM_BCM_CMD_GMA;
705734

706735
nca->data = data;
@@ -724,7 +753,7 @@ static int ncsi_oem_gma_handler_mlx(struct ncsi_cmd_arg *nca)
724753
nca->payload = NCSI_OEM_MLX_CMD_GMA_LEN;
725754

726755
memset(&u, 0, sizeof(u));
727-
u.data_u32[0] = ntohl(NCSI_OEM_MFR_MLX_ID);
756+
u.data_u32[0] = ntohl((__force __be32)NCSI_OEM_MFR_MLX_ID);
728757
u.data_u8[5] = NCSI_OEM_MLX_CMD_GMA;
729758
u.data_u8[6] = NCSI_OEM_MLX_CMD_GMA_PARAM;
730759

@@ -747,7 +776,7 @@ static int ncsi_oem_smaf_mlx(struct ncsi_cmd_arg *nca)
747776
int ret = 0;
748777

749778
memset(&u, 0, sizeof(u));
750-
u.data_u32[0] = ntohl(NCSI_OEM_MFR_MLX_ID);
779+
u.data_u32[0] = ntohl((__force __be32)NCSI_OEM_MFR_MLX_ID);
751780
u.data_u8[5] = NCSI_OEM_MLX_CMD_SMAF;
752781
u.data_u8[6] = NCSI_OEM_MLX_CMD_SMAF_PARAM;
753782
memcpy(&u.data_u8[MLX_SMAF_MAC_ADDR_OFFSET],
@@ -1391,8 +1420,24 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)
13911420
goto error;
13921421
}
13931422

1423+
nd->state = ncsi_dev_state_probe_gvi;
1424+
if (IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY))
1425+
nd->state = ncsi_dev_state_probe_keep_phy;
1426+
break;
1427+
#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY)
1428+
case ncsi_dev_state_probe_keep_phy:
1429+
ndp->pending_req_num = 1;
1430+
1431+
nca.type = NCSI_PKT_CMD_OEM;
1432+
nca.package = ndp->active_package->id;
1433+
nca.channel = 0;
1434+
ret = ncsi_oem_keep_phy_intel(&nca);
1435+
if (ret)
1436+
goto error;
1437+
13941438
nd->state = ncsi_dev_state_probe_gvi;
13951439
break;
1440+
#endif /* CONFIG_NCSI_OEM_CMD_KEEP_PHY */
13961441
case ncsi_dev_state_probe_gvi:
13971442
case ncsi_dev_state_probe_gc:
13981443
case ncsi_dev_state_probe_gls:

net/ncsi/ncsi-rsp.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static int ncsi_rsp_handler_ev(struct ncsi_request *nr)
403403
/* Update to VLAN mode */
404404
cmd = (struct ncsi_cmd_ev_pkt *)skb_network_header(nr->cmd);
405405
ncm->enable = 1;
406-
ncm->data[0] = ntohl(cmd->mode);
406+
ncm->data[0] = ntohl((__force __be32)cmd->mode);
407407

408408
return 0;
409409
}
@@ -699,12 +699,19 @@ static int ncsi_rsp_handler_oem_bcm(struct ncsi_request *nr)
699699
return 0;
700700
}
701701

702+
/* Response handler for Intel card */
703+
static int ncsi_rsp_handler_oem_intel(struct ncsi_request *nr)
704+
{
705+
return 0;
706+
}
707+
702708
static struct ncsi_rsp_oem_handler {
703709
unsigned int mfr_id;
704710
int (*handler)(struct ncsi_request *nr);
705711
} ncsi_rsp_oem_handlers[] = {
706712
{ NCSI_OEM_MFR_MLX_ID, ncsi_rsp_handler_oem_mlx },
707-
{ NCSI_OEM_MFR_BCM_ID, ncsi_rsp_handler_oem_bcm }
713+
{ NCSI_OEM_MFR_BCM_ID, ncsi_rsp_handler_oem_bcm },
714+
{ NCSI_OEM_MFR_INTEL_ID, ncsi_rsp_handler_oem_intel }
708715
};
709716

710717
/* Response handler for OEM command */

0 commit comments

Comments
 (0)