net/ncsi: Add NCSI OEM command support
[linux-2.6-block.git] / net / ncsi / ncsi-rsp.c
index 930c1d3796f0f5235875c0181af93e46016c27cd..d66b34749027f1349b56f49c2934a4c7717688bf 100644 (file)
@@ -596,6 +596,47 @@ static int ncsi_rsp_handler_snfc(struct ncsi_request *nr)
        return 0;
 }
 
+static struct ncsi_rsp_oem_handler {
+       unsigned int    mfr_id;
+       int             (*handler)(struct ncsi_request *nr);
+} ncsi_rsp_oem_handlers[] = {
+       { NCSI_OEM_MFR_MLX_ID, NULL },
+       { NCSI_OEM_MFR_BCM_ID, NULL }
+};
+
+/* Response handler for OEM command */
+static int ncsi_rsp_handler_oem(struct ncsi_request *nr)
+{
+       struct ncsi_rsp_oem_pkt *rsp;
+       struct ncsi_rsp_oem_handler *nrh = NULL;
+       unsigned int mfr_id, i;
+
+       /* Get the response header */
+       rsp = (struct ncsi_rsp_oem_pkt *)skb_network_header(nr->rsp);
+       mfr_id = ntohl(rsp->mfr_id);
+
+       /* Check for manufacturer id and Find the handler */
+       for (i = 0; i < ARRAY_SIZE(ncsi_rsp_oem_handlers); i++) {
+               if (ncsi_rsp_oem_handlers[i].mfr_id == mfr_id) {
+                       if (ncsi_rsp_oem_handlers[i].handler)
+                               nrh = &ncsi_rsp_oem_handlers[i];
+                       else
+                               nrh = NULL;
+
+                       break;
+               }
+       }
+
+       if (!nrh) {
+               netdev_err(nr->ndp->ndev.dev, "Received unrecognized OEM packet with MFR-ID (0x%x)\n",
+                          mfr_id);
+               return -ENOENT;
+       }
+
+       /* Process the packet */
+       return nrh->handler(nr);
+}
+
 static int ncsi_rsp_handler_gvi(struct ncsi_request *nr)
 {
        struct ncsi_rsp_gvi_pkt *rsp;
@@ -932,7 +973,7 @@ static struct ncsi_rsp_handler {
        { NCSI_PKT_RSP_GNS,   172, ncsi_rsp_handler_gns     },
        { NCSI_PKT_RSP_GNPTS, 172, ncsi_rsp_handler_gnpts   },
        { NCSI_PKT_RSP_GPS,     8, ncsi_rsp_handler_gps     },
-       { NCSI_PKT_RSP_OEM,     0, NULL                     },
+       { NCSI_PKT_RSP_OEM,    -1, ncsi_rsp_handler_oem     },
        { NCSI_PKT_RSP_PLDM,    0, NULL                     },
        { NCSI_PKT_RSP_GPUUID, 20, ncsi_rsp_handler_gpuuid  }
 };