]> git.baikalelectronics.ru Git - kernel.git/commitdiff
qede: Add support for reading the config id attributes.
authorSudarsana Reddy Kalluru <skalluru@marvell.com>
Fri, 30 Aug 2019 07:42:04 +0000 (00:42 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 31 Aug 2019 20:32:30 +0000 (13:32 -0700)
Add driver support for dumping the config id attributes via ethtool dump
interfaces.

Signed-off-by: Sudarsana Reddy Kalluru <skalluru@marvell.com>
Signed-off-by: Ariel Elior <aelior@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qede/qede.h
drivers/net/ethernet/qlogic/qede/qede_ethtool.c

index 0e931c04fecf481af44100298b3cd196ee263f4d..8f2adde131e4e94f936b344e3032bc31152bb4de 100644 (file)
@@ -177,6 +177,19 @@ enum qede_flags_bit {
        QEDE_FLAGS_TX_TIMESTAMPING_EN
 };
 
+#define QEDE_DUMP_MAX_ARGS 4
+enum qede_dump_cmd {
+       QEDE_DUMP_CMD_NONE = 0,
+       QEDE_DUMP_CMD_NVM_CFG,
+       QEDE_DUMP_CMD_MAX
+};
+
+struct qede_dump_info {
+       enum qede_dump_cmd cmd;
+       u8 num_args;
+       u32 args[QEDE_DUMP_MAX_ARGS];
+};
+
 struct qede_dev {
        struct qed_dev                  *cdev;
        struct net_device               *ndev;
@@ -262,6 +275,7 @@ struct qede_dev {
        struct qede_rdma_dev            rdma_info;
 
        struct bpf_prog *xdp_prog;
+       struct qede_dump_info           dump_info;
 };
 
 enum QEDE_STATE {
index abcee474909a4eec5e4e1234e6cc2d99caca492c..235929385d5ae725d5739d292b8c9f0405762b91 100644 (file)
@@ -48,6 +48,9 @@
         {QEDE_RQSTAT_OFFSET(stat_name), QEDE_RQSTAT_STRING(stat_name)}
 
 #define QEDE_SELFTEST_POLL_COUNT 100
+#define QEDE_DUMP_VERSION      0x1
+#define QEDE_DUMP_NVM_BUF_LEN  32
+#define QEDE_DUMP_NVM_ARG_COUNT        2
 
 static const struct {
        u64 offset;
@@ -1973,6 +1976,89 @@ static int qede_get_module_eeprom(struct net_device *dev,
        return rc;
 }
 
+static int qede_set_dump(struct net_device *dev, struct ethtool_dump *val)
+{
+       struct qede_dev *edev = netdev_priv(dev);
+       int rc = 0;
+
+       if (edev->dump_info.cmd == QEDE_DUMP_CMD_NONE) {
+               if (val->flag > QEDE_DUMP_CMD_MAX) {
+                       DP_ERR(edev, "Invalid command %d\n", val->flag);
+                       return -EINVAL;
+               }
+               edev->dump_info.cmd = val->flag;
+               edev->dump_info.num_args = 0;
+               return 0;
+       }
+
+       if (edev->dump_info.num_args == QEDE_DUMP_MAX_ARGS) {
+               DP_ERR(edev, "Arg count = %d\n", edev->dump_info.num_args);
+               return -EINVAL;
+       }
+
+       switch (edev->dump_info.cmd) {
+       case QEDE_DUMP_CMD_NVM_CFG:
+               edev->dump_info.args[edev->dump_info.num_args] = val->flag;
+               edev->dump_info.num_args++;
+               break;
+       default:
+               break;
+       }
+
+       return rc;
+}
+
+static int qede_get_dump_flag(struct net_device *dev,
+                             struct ethtool_dump *dump)
+{
+       struct qede_dev *edev = netdev_priv(dev);
+
+       dump->version = QEDE_DUMP_VERSION;
+       switch (edev->dump_info.cmd) {
+       case QEDE_DUMP_CMD_NVM_CFG:
+               dump->flag = QEDE_DUMP_CMD_NVM_CFG;
+               dump->len = QEDE_DUMP_NVM_BUF_LEN;
+               break;
+       default:
+               break;
+       }
+
+       DP_VERBOSE(edev, QED_MSG_DEBUG,
+                  "dump->version = 0x%x dump->flag = %d dump->len = %d\n",
+                  dump->version, dump->flag, dump->len);
+       return 0;
+}
+
+static int qede_get_dump_data(struct net_device *dev,
+                             struct ethtool_dump *dump, void *buf)
+{
+       struct qede_dev *edev = netdev_priv(dev);
+       int rc;
+
+       switch (edev->dump_info.cmd) {
+       case QEDE_DUMP_CMD_NVM_CFG:
+               if (edev->dump_info.num_args != QEDE_DUMP_NVM_ARG_COUNT) {
+                       DP_ERR(edev, "Arg count = %d required = %d\n",
+                              edev->dump_info.num_args,
+                              QEDE_DUMP_NVM_ARG_COUNT);
+                       return -EINVAL;
+               }
+               rc =  edev->ops->common->read_nvm_cfg(edev->cdev, (u8 **)&buf,
+                                                     edev->dump_info.args[0],
+                                                     edev->dump_info.args[1]);
+               break;
+       default:
+               DP_ERR(edev, "Invalid cmd = %d\n", edev->dump_info.cmd);
+               rc = -EINVAL;
+               break;
+       }
+
+       edev->dump_info.cmd = QEDE_DUMP_CMD_NONE;
+       edev->dump_info.num_args = 0;
+
+       return rc;
+}
+
 static const struct ethtool_ops qede_ethtool_ops = {
        .get_link_ksettings = qede_get_link_ksettings,
        .set_link_ksettings = qede_set_link_ksettings,
@@ -2014,6 +2100,9 @@ static const struct ethtool_ops qede_ethtool_ops = {
        .get_tunable = qede_get_tunable,
        .set_tunable = qede_set_tunable,
        .flash_device = qede_flash_device,
+       .get_dump_flag = qede_get_dump_flag,
+       .get_dump_data = qede_get_dump_data,
+       .set_dump = qede_set_dump,
 };
 
 static const struct ethtool_ops qede_vf_ethtool_ops = {