<div dir="auto">I'm just going to say that I'm very excited about these patches. Just what I needed, thanks for contributing them :-).</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 2, 2018, 03:20 Samuel Mendoza-Jonas <<a href="mailto:sam@mendozajonas.com">sam@mendozajonas.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, 2018-09-28 at 18:06 -0700, Vijay Khemka wrote:<br>
> This patch adds OEM commands and response handling. It also defines OEM<br>
> command and response structure as per NCSI specification along with its<br>
> handlers.<br>
> <br>
> ncsi_cmd_handler_oem: This is a generic command request handler for OEM<br>
> commands<br>
> ncsi_rsp_handler_oem: This is a generic response handler for OEM commands<br>
> <br>
> Signed-off-by: Vijay Khemka <<a href="mailto:vijaykhemka@fb.com" target="_blank" rel="noreferrer">vijaykhemka@fb.com</a>><br>
<br>
Hi Vijay - looks good to me, and should be a good common base for your<br>
and Justin's changes.<br>
<br>
Reviewed-by: Samuel Mendoza-Jonas <<a href="mailto:sam@mendozajonas.com" target="_blank" rel="noreferrer">sam@mendozajonas.com</a>><br>
<br>
> ---<br>
> net/ncsi/internal.h | 4 ++++<br>
> net/ncsi/ncsi-cmd.c | 31 ++++++++++++++++++++++++++++---<br>
> net/ncsi/ncsi-pkt.h | 16 ++++++++++++++++<br>
> net/ncsi/ncsi-rsp.c | 44 +++++++++++++++++++++++++++++++++++++++++++-<br>
> 4 files changed, 91 insertions(+), 4 deletions(-)<br>
> <br>
> diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h<br>
> index 8055e3965cef..c16cb7223064 100644<br>
> --- a/net/ncsi/internal.h<br>
> +++ b/net/ncsi/internal.h<br>
> @@ -68,6 +68,10 @@ enum {<br>
> NCSI_MODE_MAX<br>
> };<br>
> <br>
> +/* OEM Vendor Manufacture ID */<br>
> +#define NCSI_OEM_MFR_MLX_ID 0x8119<br>
> +#define NCSI_OEM_MFR_BCM_ID 0x113d<br>
> +<br>
> struct ncsi_channel_version {<br>
> u32 version; /* Supported BCD encoded NCSI version */<br>
> u32 alpha2; /* Supported BCD encoded NCSI version */<br>
> diff --git a/net/ncsi/ncsi-cmd.c b/net/ncsi/ncsi-cmd.c<br>
> index 7567ca63aae2..2f98533eba46 100644<br>
> --- a/net/ncsi/ncsi-cmd.c<br>
> +++ b/net/ncsi/ncsi-cmd.c<br>
> @@ -211,6 +211,26 @@ static int ncsi_cmd_handler_snfc(struct sk_buff *skb,<br>
> return 0;<br>
> }<br>
> <br>
> +static int ncsi_cmd_handler_oem(struct sk_buff *skb,<br>
> + struct ncsi_cmd_arg *nca)<br>
> +{<br>
> + struct ncsi_cmd_oem_pkt *cmd;<br>
> + unsigned int len;<br>
> +<br>
> + len = sizeof(struct ncsi_cmd_pkt_hdr) + 4;<br>
> + if (nca->payload < 26)<br>
> + len += 26;<br>
> + else<br>
> + len += nca->payload;<br>
> +<br>
> + cmd = skb_put_zero(skb, len);<br>
> + cmd->mfr_id = nca->dwords[0];<br>
> + memcpy(cmd->data, &nca->dwords[1], nca->payload - 4);<br>
> + ncsi_cmd_build_header(&cmd->cmd.common, nca);<br>
> +<br>
> + return 0;<br>
> +}<br>
> +<br>
> static struct ncsi_cmd_handler {<br>
> unsigned char type;<br>
> int payload;<br>
> @@ -244,7 +264,7 @@ static struct ncsi_cmd_handler {<br>
> { NCSI_PKT_CMD_GNS, 0, ncsi_cmd_handler_default },<br>
> { NCSI_PKT_CMD_GNPTS, 0, ncsi_cmd_handler_default },<br>
> { NCSI_PKT_CMD_GPS, 0, ncsi_cmd_handler_default },<br>
> - { NCSI_PKT_CMD_OEM, 0, NULL },<br>
> + { NCSI_PKT_CMD_OEM, -1, ncsi_cmd_handler_oem },<br>
> { NCSI_PKT_CMD_PLDM, 0, NULL },<br>
> { NCSI_PKT_CMD_GPUUID, 0, ncsi_cmd_handler_default }<br>
> };<br>
> @@ -316,8 +336,13 @@ int ncsi_xmit_cmd(struct ncsi_cmd_arg *nca)<br>
> return -ENOENT;<br>
> }<br>
> <br>
> - /* Get packet payload length and allocate the request */<br>
> - nca->payload = nch->payload;<br>
> + /* Get packet payload length and allocate the request<br>
> + * It is expected that if length set as negative in<br>
> + * handler structure means caller is initializing it<br>
> + * and setting length in nca before calling xmit function<br>
> + */<br>
> + if (nch->payload >= 0)<br>
> + nca->payload = nch->payload;<br>
> nr = ncsi_alloc_command(nca);<br>
> if (!nr)<br>
> return -ENOMEM;<br>
> diff --git a/net/ncsi/ncsi-pkt.h b/net/ncsi/ncsi-pkt.h<br>
> index 91b4b66438df..1f338386810d 100644<br>
> --- a/net/ncsi/ncsi-pkt.h<br>
> +++ b/net/ncsi/ncsi-pkt.h<br>
> @@ -151,6 +151,22 @@ struct ncsi_cmd_snfc_pkt {<br>
> unsigned char pad[22];<br>
> };<br>
> <br>
> +/* OEM Request Command as per NCSI Specification */<br>
> +struct ncsi_cmd_oem_pkt {<br>
> + struct ncsi_cmd_pkt_hdr cmd; /* Command header */<br>
> + __be32 mfr_id; /* Manufacture ID */<br>
> + unsigned char data[64]; /* OEM Payload Data */<br>
> + __be32 checksum; /* Checksum */<br>
> +};<br>
> +<br>
> +/* OEM Response Packet as per NCSI Specification */<br>
> +struct ncsi_rsp_oem_pkt {<br>
> + struct ncsi_rsp_pkt_hdr rsp; /* Command header */<br>
> + __be32 mfr_id; /* Manufacture ID */<br>
> + unsigned char data[64]; /* Payload data */<br>
> + __be32 checksum; /* Checksum */<br>
> +};<br>
> +<br>
> /* Get Link Status */<br>
> struct ncsi_rsp_gls_pkt {<br>
> struct ncsi_rsp_pkt_hdr rsp; /* Response header */<br>
> diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c<br>
> index 930c1d3796f0..22664ebdc93a 100644<br>
> --- a/net/ncsi/ncsi-rsp.c<br>
> +++ b/net/ncsi/ncsi-rsp.c<br>
> @@ -596,6 +596,48 @@ static int ncsi_rsp_handler_snfc(struct ncsi_request *nr)<br>
> return 0;<br>
> }<br>
> <br>
> +static struct ncsi_rsp_oem_handler {<br>
> + unsigned int mfr_id;<br>
> + int (*handler)(struct ncsi_request *nr);<br>
> +} ncsi_rsp_oem_handlers[] = {<br>
> + { NCSI_OEM_MFR_MLX_ID, NULL },<br>
> + { NCSI_OEM_MFR_BCM_ID, NULL }<br>
> +};<br>
> +<br>
> +<br>
> +/* Response handler for OEM command */<br>
> +static int ncsi_rsp_handler_oem(struct ncsi_request *nr)<br>
> +{<br>
> + struct ncsi_rsp_oem_pkt *rsp;<br>
> + struct ncsi_rsp_oem_handler *nrh = NULL;<br>
> + unsigned int mfr_id, i;<br>
> +<br>
> + /* Get the response header */<br>
> + rsp = (struct ncsi_rsp_oem_pkt *)skb_network_header(nr->rsp);<br>
> + mfr_id = ntohl(rsp->mfr_id);<br>
> +<br>
> + /* Check for manufacturer id and Find the handler */<br>
> + for (i = 0; i < ARRAY_SIZE(ncsi_rsp_oem_handlers); i++) {<br>
> + if (ncsi_rsp_oem_handlers[i].mfr_id == mfr_id) {<br>
> + if (ncsi_rsp_oem_handlers[i].handler)<br>
> + nrh = &ncsi_rsp_oem_handlers[i];<br>
> + else<br>
> + nrh = NULL;<br>
> +<br>
> + break;<br>
> + }<br>
> + }<br>
> +<br>
> + if (!nrh) {<br>
> + netdev_err(nr->ndp->ndev.dev, "Received unrecognized OEM packet with MFR-ID (0x%x)\n",<br>
> + mfr_id);<br>
> + return -ENOENT;<br>
> + }<br>
> +<br>
> + /* Process the packet */<br>
> + return nrh->handler(nr);<br>
> +}<br>
> +<br>
> static int ncsi_rsp_handler_gvi(struct ncsi_request *nr)<br>
> {<br>
> struct ncsi_rsp_gvi_pkt *rsp;<br>
> @@ -932,7 +974,7 @@ static struct ncsi_rsp_handler {<br>
> { NCSI_PKT_RSP_GNS, 172, ncsi_rsp_handler_gns },<br>
> { NCSI_PKT_RSP_GNPTS, 172, ncsi_rsp_handler_gnpts },<br>
> { NCSI_PKT_RSP_GPS, 8, ncsi_rsp_handler_gps },<br>
> - { NCSI_PKT_RSP_OEM, 0, NULL },<br>
> + { NCSI_PKT_RSP_OEM, -1, ncsi_rsp_handler_oem },<br>
> { NCSI_PKT_RSP_PLDM, 0, NULL },<br>
> { NCSI_PKT_RSP_GPUUID, 20, ncsi_rsp_handler_gpuuid }<br>
> };<br>
<br>
<br>
</blockquote></div>