RE: [EXT] [PATCH] bnx2x: Fix potential infinite loop

2021-04-07 Thread Sudarsana Reddy Kalluru

> -Original Message-
> From: Colin King 
> Sent: Wednesday, April 7, 2021 7:58 PM
> To: Ariel Elior ; Sudarsana Reddy Kalluru
> ; GR-everest-linux-l2  l...@marvell.com>; David S . Miller ; Jakub Kicinski
> ; Eilon Greenstein ;
> netdev@vger.kernel.org
> Cc: kernel-janit...@vger.kernel.org; linux-ker...@vger.kernel.org
> Subject: [EXT] [PATCH] bnx2x: Fix potential infinite loop
> 
> External Email
> 
> --
> From: Colin Ian King 
> 
> The for_each_tx_queue loop iterates with a u8 loop counter i and compares
> this with the loop upper limit of bp->num_queues that is an int type.  There
> is a potential infinite loop if bp->num_queues is larger than the u8 loop
> counter. Fix this by making the loop counter the same type as bp-
> >num_queues.
> 
> Addresses-Coverity: ("Infinite loop")
> Fixes: ad5afc89365e ("bnx2x: Separate VF and PF logic")
> Signed-off-by: Colin Ian King 
> ---
>  drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> index 1a6ec1a12d53..edfbeb710ad4 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> @@ -2959,7 +2959,8 @@ int bnx2x_nic_load(struct bnx2x *bp, int
> load_mode)
> 
>  int bnx2x_drain_tx_queues(struct bnx2x *bp)  {
> - u8 rc = 0, cos, i;
> + u8 rc = 0, cos;
> + int i;
> 
>   /* Wait until tx fastpath tasks complete */
>   for_each_tx_queue(bp, i) {
> --
> 2.30.2

Thanks for the change. [just for the info, theoretical max num_queues value for 
bnx2x device is 33]

Acked-by: Sudarsana Reddy Kalluru 


[PATCH net v3 1/1] qed: Populate nvm-file attributes while reading nvm config partition.

2020-07-08 Thread Sudarsana Reddy Kalluru
NVM config file address will be modified when the MBI image is upgraded.
Driver would return stale config values if user reads the nvm-config
(via ethtool -d) in this state. The fix is to re-populate nvm attribute
info while reading the nvm config values/partition.

Changes from previous version:
---
v3: Corrected the formatting in 'Fixes' tag.
v2: Added 'Fixes' tag.

Fixes: 1ac4329a1cff ("qed: Add configuration information to register dump and 
debug data")
Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
---
 drivers/net/ethernet/qlogic/qed/qed_debug.c |  4 
 drivers/net/ethernet/qlogic/qed/qed_dev.c   | 12 +++-
 drivers/net/ethernet/qlogic/qed/qed_mcp.c   |  7 +++
 drivers/net/ethernet/qlogic/qed/qed_mcp.h   |  7 +++
 4 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c 
b/drivers/net/ethernet/qlogic/qed/qed_debug.c
index cb80863..3b9bbaf 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_debug.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c
@@ -7941,6 +7941,10 @@ int qed_dbg_all_data(struct qed_dev *cdev, void *buffer)
DP_ERR(cdev, "qed_dbg_mcp_trace failed. rc = %d\n", rc);
}
 
+   /* Re-populate nvm attribute info */
+   qed_mcp_nvm_info_free(p_hwfn);
+   qed_mcp_nvm_info_populate(p_hwfn);
+
/* nvm cfg1 */
rc = qed_dbg_nvm_image(cdev,
   (u8 *)buffer + offset +
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 3aa5137..9c26fde 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -4472,12 +4472,6 @@ static int qed_get_dev_info(struct qed_hwfn *p_hwfn, 
struct qed_ptt *p_ptt)
return 0;
 }
 
-static void qed_nvm_info_free(struct qed_hwfn *p_hwfn)
-{
-   kfree(p_hwfn->nvm_info.image_att);
-   p_hwfn->nvm_info.image_att = NULL;
-}
-
 static int qed_hw_prepare_single(struct qed_hwfn *p_hwfn,
 void __iomem *p_regview,
 void __iomem *p_doorbells,
@@ -4562,7 +4556,7 @@ static int qed_hw_prepare_single(struct qed_hwfn *p_hwfn,
return rc;
 err3:
if (IS_LEAD_HWFN(p_hwfn))
-   qed_nvm_info_free(p_hwfn);
+   qed_mcp_nvm_info_free(p_hwfn);
 err2:
if (IS_LEAD_HWFN(p_hwfn))
qed_iov_free_hw_info(p_hwfn->cdev);
@@ -4623,7 +4617,7 @@ int qed_hw_prepare(struct qed_dev *cdev,
if (rc) {
if (IS_PF(cdev)) {
qed_init_free(p_hwfn);
-   qed_nvm_info_free(p_hwfn);
+   qed_mcp_nvm_info_free(p_hwfn);
qed_mcp_free(p_hwfn);
qed_hw_hwfn_free(p_hwfn);
}
@@ -4657,7 +4651,7 @@ void qed_hw_remove(struct qed_dev *cdev)
 
qed_iov_free_hw_info(cdev);
 
-   qed_nvm_info_free(p_hwfn);
+   qed_mcp_nvm_info_free(p_hwfn);
 }
 
 static void qed_chain_free_next_ptr(struct qed_dev *cdev,
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index 9624616..0fd4520 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -3280,6 +3280,13 @@ int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn)
return rc;
 }
 
+void qed_mcp_nvm_info_free(struct qed_hwfn *p_hwfn)
+{
+   kfree(p_hwfn->nvm_info.image_att);
+   p_hwfn->nvm_info.image_att = NULL;
+   p_hwfn->nvm_info.valid = false;
+}
+
 int
 qed_mcp_get_nvm_image_att(struct qed_hwfn *p_hwfn,
  enum qed_nvm_images image_id,
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.h 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
index 5750b4c..12a705e 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
@@ -1221,6 +1221,13 @@ void qed_mcp_resc_lock_default_init(struct 
qed_resc_lock_params *p_lock,
 int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn);
 
 /**
+ * @brief Delete nvm info shadow in the given hardware function
+ *
+ * @param p_hwfn
+ */
+void qed_mcp_nvm_info_free(struct qed_hwfn *p_hwfn);
+
+/**
  * @brief Get the engine affinity configuration.
  *
  * @param p_hwfn
-- 
1.8.3.1



[PATCH net v2 1/1] qed: Populate nvm-file attributes while reading nvm config partition.

2020-07-07 Thread Sudarsana Reddy Kalluru
NVM config file address will be modified when the MBI image is upgraded.
Driver would return stale config values if user reads the nvm-config
(via ethtool -d) in this state. The fix is to re-populate nvm attribute
info while reading the nvm config values/partition.

Changes from previous version:
---
v2: Added 'Fixes' tag.

Fixes: 1ac4329a1cff (qed: Add configuration information to register dump and 
debug data)
Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
---
 drivers/net/ethernet/qlogic/qed/qed_debug.c |  4 
 drivers/net/ethernet/qlogic/qed/qed_dev.c   | 12 +++-
 drivers/net/ethernet/qlogic/qed/qed_mcp.c   |  7 +++
 drivers/net/ethernet/qlogic/qed/qed_mcp.h   |  7 +++
 4 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c 
b/drivers/net/ethernet/qlogic/qed/qed_debug.c
index cb80863..3b9bbaf 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_debug.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c
@@ -7941,6 +7941,10 @@ int qed_dbg_all_data(struct qed_dev *cdev, void *buffer)
DP_ERR(cdev, "qed_dbg_mcp_trace failed. rc = %d\n", rc);
}
 
+   /* Re-populate nvm attribute info */
+   qed_mcp_nvm_info_free(p_hwfn);
+   qed_mcp_nvm_info_populate(p_hwfn);
+
/* nvm cfg1 */
rc = qed_dbg_nvm_image(cdev,
   (u8 *)buffer + offset +
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 3aa5137..9c26fde 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -4472,12 +4472,6 @@ static int qed_get_dev_info(struct qed_hwfn *p_hwfn, 
struct qed_ptt *p_ptt)
return 0;
 }
 
-static void qed_nvm_info_free(struct qed_hwfn *p_hwfn)
-{
-   kfree(p_hwfn->nvm_info.image_att);
-   p_hwfn->nvm_info.image_att = NULL;
-}
-
 static int qed_hw_prepare_single(struct qed_hwfn *p_hwfn,
 void __iomem *p_regview,
 void __iomem *p_doorbells,
@@ -4562,7 +4556,7 @@ static int qed_hw_prepare_single(struct qed_hwfn *p_hwfn,
return rc;
 err3:
if (IS_LEAD_HWFN(p_hwfn))
-   qed_nvm_info_free(p_hwfn);
+   qed_mcp_nvm_info_free(p_hwfn);
 err2:
if (IS_LEAD_HWFN(p_hwfn))
qed_iov_free_hw_info(p_hwfn->cdev);
@@ -4623,7 +4617,7 @@ int qed_hw_prepare(struct qed_dev *cdev,
if (rc) {
if (IS_PF(cdev)) {
qed_init_free(p_hwfn);
-   qed_nvm_info_free(p_hwfn);
+   qed_mcp_nvm_info_free(p_hwfn);
qed_mcp_free(p_hwfn);
qed_hw_hwfn_free(p_hwfn);
}
@@ -4657,7 +4651,7 @@ void qed_hw_remove(struct qed_dev *cdev)
 
qed_iov_free_hw_info(cdev);
 
-   qed_nvm_info_free(p_hwfn);
+   qed_mcp_nvm_info_free(p_hwfn);
 }
 
 static void qed_chain_free_next_ptr(struct qed_dev *cdev,
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index 9624616..0fd4520 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -3280,6 +3280,13 @@ int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn)
return rc;
 }
 
+void qed_mcp_nvm_info_free(struct qed_hwfn *p_hwfn)
+{
+   kfree(p_hwfn->nvm_info.image_att);
+   p_hwfn->nvm_info.image_att = NULL;
+   p_hwfn->nvm_info.valid = false;
+}
+
 int
 qed_mcp_get_nvm_image_att(struct qed_hwfn *p_hwfn,
  enum qed_nvm_images image_id,
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.h 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
index 5750b4c..12a705e 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
@@ -1221,6 +1221,13 @@ void qed_mcp_resc_lock_default_init(struct 
qed_resc_lock_params *p_lock,
 int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn);
 
 /**
+ * @brief Delete nvm info shadow in the given hardware function
+ *
+ * @param p_hwfn
+ */
+void qed_mcp_nvm_info_free(struct qed_hwfn *p_hwfn);
+
+/**
  * @brief Get the engine affinity configuration.
  *
  * @param p_hwfn
-- 
1.8.3.1



[PATCH net-next v3 2/3] bnx2x: Add support for idlechk tests.

2020-07-03 Thread Sudarsana Reddy Kalluru
This patch populates a database of idlechk tests (registers and
predicates) and performs the idlechk using this data.

Signed-off-by: Sudarsana Reddy Kalluru 
---
 drivers/net/ethernet/broadcom/bnx2x/Makefile   |2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h|   10 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |7 +
 .../net/ethernet/broadcom/bnx2x/bnx2x_self_test.c  | 3183 
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c  |2 +
 5 files changed, 3196 insertions(+), 8 deletions(-)
 create mode 100644 drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c

diff --git a/drivers/net/ethernet/broadcom/bnx2x/Makefile 
b/drivers/net/ethernet/broadcom/bnx2x/Makefile
index 9fdfaa2..2523cfc 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/Makefile
+++ b/drivers/net/ethernet/broadcom/bnx2x/Makefile
@@ -5,5 +5,5 @@
 
 obj-$(CONFIG_BNX2X) += bnx2x.o
 
-bnx2x-y := bnx2x_main.o bnx2x_link.o bnx2x_cmn.o bnx2x_ethtool.o bnx2x_stats.o 
bnx2x_dcb.o bnx2x_sp.o
+bnx2x-y := bnx2x_main.o bnx2x_link.o bnx2x_cmn.o bnx2x_ethtool.o bnx2x_stats.o 
bnx2x_dcb.o bnx2x_sp.o bnx2x_self_test.o
 bnx2x-$(CONFIG_BNX2X_SRIOV) += bnx2x_vfpf.o bnx2x_sriov.o
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 4f5b2b8..dee61d9 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -1979,6 +1979,9 @@ struct bnx2x_func_init_params {
 
 #define skip_queue(bp, idx)(NO_FCOE(bp) && IS_FCOE_IDX(idx))
 
+/*self test*/
+int bnx2x_idle_chk(struct bnx2x *bp);
+
 /**
  * bnx2x_set_mac_one - configure a single MAC address
  *
@@ -2430,13 +2433,6 @@ void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, 
u8 idu_sb_id,
 #define HC_SEG_ACCESS_ATTN 4
 #define HC_SEG_ACCESS_NORM 0   /*Driver decision 0-1*/
 
-static const u32 dmae_reg_go_c[] = {
-   DMAE_REG_GO_C0, DMAE_REG_GO_C1, DMAE_REG_GO_C2, DMAE_REG_GO_C3,
-   DMAE_REG_GO_C4, DMAE_REG_GO_C5, DMAE_REG_GO_C6, DMAE_REG_GO_C7,
-   DMAE_REG_GO_C8, DMAE_REG_GO_C9, DMAE_REG_GO_C10, DMAE_REG_GO_C11,
-   DMAE_REG_GO_C12, DMAE_REG_GO_C13, DMAE_REG_GO_C14, DMAE_REG_GO_C15
-};
-
 void bnx2x_set_ethtool_ops(struct bnx2x *bp, struct net_device *netdev);
 void bnx2x_notify_link_changed(struct bnx2x *bp);
 
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index db5107e7..06dfb90 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -276,6 +276,13 @@ enum bnx2x_board_type {
 
 MODULE_DEVICE_TABLE(pci, bnx2x_pci_tbl);
 
+const u32 dmae_reg_go_c[] = {
+   DMAE_REG_GO_C0, DMAE_REG_GO_C1, DMAE_REG_GO_C2, DMAE_REG_GO_C3,
+   DMAE_REG_GO_C4, DMAE_REG_GO_C5, DMAE_REG_GO_C6, DMAE_REG_GO_C7,
+   DMAE_REG_GO_C8, DMAE_REG_GO_C9, DMAE_REG_GO_C10, DMAE_REG_GO_C11,
+   DMAE_REG_GO_C12, DMAE_REG_GO_C13, DMAE_REG_GO_C14, DMAE_REG_GO_C15
+};
+
 /* Global resources for unloading a previously loaded device */
 #define BNX2X_PREV_WAIT_NEEDED 1
 static DEFINE_SEMAPHORE(bnx2x_prev_sem);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c
new file mode 100644
index 000..48f63ef
--- /dev/null
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c
@@ -0,0 +1,3183 @@
+// SPDX-License-Identifier: GPL-2.0
+#include 
+#include 
+#include "bnx2x.h"
+
+#define NA 0xCD
+
+#define IDLE_CHK_E10x01
+#define IDLE_CHK_E1H   0x02
+#define IDLE_CHK_E20x04
+#define IDLE_CHK_E3A0  0x08
+#define IDLE_CHK_E3B0  0x10
+
+#define IDLE_CHK_ERROR 1
+#define IDLE_CHK_ERROR_NO_TRAFFIC  2
+#define IDLE_CHK_WARNING   3
+
+#define MAX_FAIL_MSG 256
+
+/* statistics and error reporting */
+static int idle_chk_errors, idle_chk_warnings;
+
+/* masks for all chip types */
+static int is_e1, is_e1h, is_e2, is_e3a0, is_e3b0;
+
+/* struct for the argument list for a predicate in the self test databasei */
+struct st_pred_args {
+   u32 val1; /* value read from first register */
+   u32 val2; /* value read from second register, if applicable */
+   u32 imm1; /* 1st value in predicate condition, left-to-right */
+   u32 imm2; /* 2nd value in predicate condition, left-to-right */
+   u32 imm3; /* 3rd value in predicate condition, left-to-right */
+   u32 imm4; /* 4th value in predicate condition, left-to-right */
+};
+
+/* struct representing self test record - a single test */
+struct st_record {
+   u8 chip_mask;
+   u8 macro;
+   u32 reg1;
+   u32 reg2;
+   u16 loop;
+   u16 incr;
+   int (*bnx2x_predicate)(struct st_pred_args *pred_args);
+   u32 reg3;
+   u8 severity;
+   char *fail_msg;
+   struct st_pred_args pred_args;
+};
+
+/* predic

[PATCH net-next v3 0/3] bnx2x: Perform IdleChk dump.

2020-07-03 Thread Sudarsana Reddy Kalluru
Idlechk test verifies that the chip is in idle state. If there are any
errors, Idlechk dump would capture the same. This data will help in
debugging the device related issues.
The patch series adds driver support for dumping IdleChk data during the
debug dump collection.
Patch (1) adds register definitions required in this implementation.
Patch (2) adds the implementation for Idlechk tests.
Patch (3) adds driver changes to invoke Idlechk implementation.


Changes from previous version:
---
v3: Combined the test data creation and implementation to a single patch.
v2: Addressed issues reported by kernel test robot.


Please consider applying to net-next tree.


Sudarsana Reddy Kalluru (3):
  bnx2x: Add Idlechk related register definitions.
  bnx2x: Add support for idlechk tests.
  bnx2x: Perform Idlechk dump during the debug collection.

 drivers/net/ethernet/broadcom/bnx2x/Makefile   |2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h|   10 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |   16 +
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h|   78 +-
 .../net/ethernet/broadcom/bnx2x/bnx2x_self_test.c  | 3183 
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c  |2 +
 6 files changed, 3281 insertions(+), 10 deletions(-)
 create mode 100644 drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c

-- 
1.8.3.1



[PATCH net-next v3 3/3] bnx2x: Perform Idlechk dump during the debug collection.

2020-07-03 Thread Sudarsana Reddy Kalluru
The patch adds driver changes to perform Idlechk dump during the debug
data collection.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 06dfb90..7c2194f 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -1176,9 +1176,18 @@ void bnx2x_panic_dump(struct bnx2x *bp, bool disable_int)
}
 #endif
if (IS_PF(bp)) {
+   int tmp_msg_en = bp->msg_enable;
+
bnx2x_fw_dump(bp);
+   bp->msg_enable |= NETIF_MSG_HW;
+   BNX2X_ERR("Idle check (1st round) --\n");
+   bnx2x_idle_chk(bp);
+   BNX2X_ERR("Idle check (2nd round) --\n");
+   bnx2x_idle_chk(bp);
+   bp->msg_enable = tmp_msg_en;
bnx2x_mc_assert(bp);
}
+
BNX2X_ERR("end crash dump -\n");
 }
 
-- 
1.8.3.1



[PATCH net-next v3 1/3] bnx2x: Add Idlechk related register definitions.

2020-07-03 Thread Sudarsana Reddy Kalluru
The patch adds register definitions required for Idlechk implementation.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h | 78 -
 1 file changed, 76 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
index a43dea2..bfc0e45 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
@@ -7639,6 +7639,82 @@
(0x80 | ((_type)&0xf << 3) | ((CDU_CRC8(_cid, _region, _type)) & 0x7))
 #define CDU_RSRVD_INVALIDATE_CONTEXT_VALUE(_val) ((_val) & ~0x80)
 
+/* IdleChk registers */
+#define PXP_REG_HST_VF_DISABLED_ERROR_VALID 0x1030bc
+#define PXP_REG_HST_VF_DISABLED_ERROR_DATA  0x1030b8
+#define PXP_REG_HST_PER_VIOLATION_VALID 
0x1030e0
+#define PXP_REG_HST_INCORRECT_ACCESS_VALID  0x1030cc
+#define PXP2_REG_RD_CPL_ERR_DETAILS 0x120778
+#define PXP2_REG_RD_CPL_ERR_DETAILS20x12077c
+#define PXP2_REG_RQ_GARB0x120748
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q00x15c1bc
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q10x15c1c0
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q20x15c1c4
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q30x15c1c8
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q40x15c1cc
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q50x15c1d0
+#define PBF_REG_CREDIT_Q2   0x140344
+#define PBF_REG_CREDIT_Q3   0x140348
+#define PBF_REG_CREDIT_Q4   0x14034c
+#define PBF_REG_CREDIT_Q5   0x140350
+#define PBF_REG_INIT_CRD_Q2 0x15c238
+#define PBF_REG_INIT_CRD_Q3 0x15c23c
+#define PBF_REG_INIT_CRD_Q4 0x15c240
+#define PBF_REG_INIT_CRD_Q5 0x15c244
+#define PBF_REG_TASK_CNT_Q0 0x140374
+#define PBF_REG_TASK_CNT_Q1 0x140378
+#define PBF_REG_TASK_CNT_Q2 0x14037c
+#define PBF_REG_TASK_CNT_Q3 0x140380
+#define PBF_REG_TASK_CNT_Q4 0x140384
+#define PBF_REG_TASK_CNT_Q5 0x140388
+#define PBF_REG_TASK_CNT_LB_Q   0x140370
+#define QM_REG_BYTECRD0 
0x16e6fc
+#define QM_REG_BYTECRD1 
0x16e700
+#define QM_REG_BYTECRD2 
0x16e704
+#define QM_REG_BYTECRD3 
0x16e7ac
+#define QM_REG_BYTECRD4 
0x16e7b0
+#define QM_REG_BYTECRD5 
0x16e7b4
+#define QM_REG_BYTECRD6 
0x16e7b8
+#define QM_REG_BYTECRDCMDQ_00x16e6e8
+#define QM_REG_BYTECRDERRREG0x16e708
+#define MISC_REG_GRC_TIMEOUT_ATTN_FULL_FID  0xa714
+#define QM_REG_VOQCREDIT_2  0x1682d8
+#define QM_REG_VOQCREDIT_3  0x1682dc
+#define QM_REG_VOQCREDIT_5  0x1682e4
+#define QM_REG_VOQCREDIT_6  0x1682e8
+#define QM_REG_VOQINITCREDIT_3  0x16806c
+#define QM_REG_VOQINITCREDIT_6  0x168078
+#define QM_REG_FWVOQ0TOHWVOQ0x16e7bc
+#define QM_REG_FWVOQ1TOHWVOQ0x16e7c0
+#define QM_REG_FWVOQ2TOHWVOQ0x16e7c4
+#define QM_REG_FWVOQ3TOHWVOQ0x16e7c8
+#define QM_REG_FWVOQ4TOHWVOQ0x16e7cc
+#define QM_REG_FWVOQ5TOHWVOQ0x16e7d0
+#define QM_REG_FWVOQ6TOHWVOQ0x16e7d4
+#define QM_REG_FWVOQ7TOHWVOQ0x16e7d8
+#define NIG_REG_INGRESS_EOP_PORT0_EMPTY 0x104ec
+#define NIG_REG_INGRESS_EOP_PORT1_EMPTY 0x104f8
+#define NIG_REG_INGRESS_RMP0_DSCR_EMPTY 0x10530
+#define NIG_REG_INGRESS_RMP1_DSCR_EMPTY   

RE: [EXT] Re: [PATCH net-next v2 2/4] bnx2x: Populate database for Idlechk tests.

2020-07-03 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: David Miller 
> Sent: Saturday, July 4, 2020 1:34 AM
> To: Sudarsana Reddy Kalluru 
> Cc: netdev@vger.kernel.org; Ariel Elior ; Igor Russkikh
> ; Michal Kalderon 
> Subject: [EXT] Re: [PATCH net-next v2 2/4] bnx2x: Populate database for
> Idlechk tests.
> 
> External Email
> 
> --
> From: David Miller 
> Date: Fri, 03 Jul 2020 13:03:07 -0700 (PDT)
> 
> > From: Sudarsana Reddy Kalluru 
> > Date: Fri, 3 Jul 2020 17:39:48 +0530
> >
> >> +/* struct holding the database of self test checks (registers and
> >> +predicates) */
> >> +/* lines start from 2 since line 1 is heading in csv */ #define
> >> +ST_DB_LINES 468 struct st_record st_database[ST_DB_LINES] = {
> >
> > This will introduce a build warning because there is no external
> > declaration for this global variable.
> >
> > A patch series must be fully bisectable, meaning that you can't just
> > add this declaration in a future patch in the series.  It has to be
> > added in the same patch where the symbol is defined.
> 
> Actually, looking further, it's even worse.
> 
> You mark it global here, and then mark it static in the next patch.
> 
> Don't do that please.

Dave, thanks for your review and the inputs. Will add the implementation in a 
single patch, and provide version 3 of the series.
Sorry for the inconvenience.


[PATCH net-next v2 1/4] bnx2x: Add Idlechk related register definitions.

2020-07-03 Thread Sudarsana Reddy Kalluru
The patch adds register definitions required for Idlechk implementation.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h | 78 -
 1 file changed, 76 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
index a43dea2..bfc0e45 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
@@ -7639,6 +7639,82 @@
(0x80 | ((_type)&0xf << 3) | ((CDU_CRC8(_cid, _region, _type)) & 0x7))
 #define CDU_RSRVD_INVALIDATE_CONTEXT_VALUE(_val) ((_val) & ~0x80)
 
+/* IdleChk registers */
+#define PXP_REG_HST_VF_DISABLED_ERROR_VALID 0x1030bc
+#define PXP_REG_HST_VF_DISABLED_ERROR_DATA  0x1030b8
+#define PXP_REG_HST_PER_VIOLATION_VALID 
0x1030e0
+#define PXP_REG_HST_INCORRECT_ACCESS_VALID  0x1030cc
+#define PXP2_REG_RD_CPL_ERR_DETAILS 0x120778
+#define PXP2_REG_RD_CPL_ERR_DETAILS20x12077c
+#define PXP2_REG_RQ_GARB0x120748
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q00x15c1bc
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q10x15c1c0
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q20x15c1c4
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q30x15c1c8
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q40x15c1cc
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q50x15c1d0
+#define PBF_REG_CREDIT_Q2   0x140344
+#define PBF_REG_CREDIT_Q3   0x140348
+#define PBF_REG_CREDIT_Q4   0x14034c
+#define PBF_REG_CREDIT_Q5   0x140350
+#define PBF_REG_INIT_CRD_Q2 0x15c238
+#define PBF_REG_INIT_CRD_Q3 0x15c23c
+#define PBF_REG_INIT_CRD_Q4 0x15c240
+#define PBF_REG_INIT_CRD_Q5 0x15c244
+#define PBF_REG_TASK_CNT_Q0 0x140374
+#define PBF_REG_TASK_CNT_Q1 0x140378
+#define PBF_REG_TASK_CNT_Q2 0x14037c
+#define PBF_REG_TASK_CNT_Q3 0x140380
+#define PBF_REG_TASK_CNT_Q4 0x140384
+#define PBF_REG_TASK_CNT_Q5 0x140388
+#define PBF_REG_TASK_CNT_LB_Q   0x140370
+#define QM_REG_BYTECRD0 
0x16e6fc
+#define QM_REG_BYTECRD1 
0x16e700
+#define QM_REG_BYTECRD2 
0x16e704
+#define QM_REG_BYTECRD3 
0x16e7ac
+#define QM_REG_BYTECRD4 
0x16e7b0
+#define QM_REG_BYTECRD5 
0x16e7b4
+#define QM_REG_BYTECRD6 
0x16e7b8
+#define QM_REG_BYTECRDCMDQ_00x16e6e8
+#define QM_REG_BYTECRDERRREG0x16e708
+#define MISC_REG_GRC_TIMEOUT_ATTN_FULL_FID  0xa714
+#define QM_REG_VOQCREDIT_2  0x1682d8
+#define QM_REG_VOQCREDIT_3  0x1682dc
+#define QM_REG_VOQCREDIT_5  0x1682e4
+#define QM_REG_VOQCREDIT_6  0x1682e8
+#define QM_REG_VOQINITCREDIT_3  0x16806c
+#define QM_REG_VOQINITCREDIT_6  0x168078
+#define QM_REG_FWVOQ0TOHWVOQ0x16e7bc
+#define QM_REG_FWVOQ1TOHWVOQ0x16e7c0
+#define QM_REG_FWVOQ2TOHWVOQ0x16e7c4
+#define QM_REG_FWVOQ3TOHWVOQ0x16e7c8
+#define QM_REG_FWVOQ4TOHWVOQ0x16e7cc
+#define QM_REG_FWVOQ5TOHWVOQ0x16e7d0
+#define QM_REG_FWVOQ6TOHWVOQ0x16e7d4
+#define QM_REG_FWVOQ7TOHWVOQ0x16e7d8
+#define NIG_REG_INGRESS_EOP_PORT0_EMPTY 0x104ec
+#define NIG_REG_INGRESS_EOP_PORT1_EMPTY 0x104f8
+#define NIG_REG_INGRESS_RMP0_DSCR_EMPTY 0x10530
+#define NIG_REG_INGRESS_RMP1_DSCR_EMPTY   

[PATCH net-next v2 4/4] bnx2x: Perform Idlechk dump during the debug collection.

2020-07-03 Thread Sudarsana Reddy Kalluru
The patch adds driver changes to perform Idlechk dump during the debug
data collection.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 06dfb90..7c2194f 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -1176,9 +1176,18 @@ void bnx2x_panic_dump(struct bnx2x *bp, bool disable_int)
}
 #endif
if (IS_PF(bp)) {
+   int tmp_msg_en = bp->msg_enable;
+
bnx2x_fw_dump(bp);
+   bp->msg_enable |= NETIF_MSG_HW;
+   BNX2X_ERR("Idle check (1st round) --\n");
+   bnx2x_idle_chk(bp);
+   BNX2X_ERR("Idle check (2nd round) --\n");
+   bnx2x_idle_chk(bp);
+   bp->msg_enable = tmp_msg_en;
bnx2x_mc_assert(bp);
}
+
BNX2X_ERR("end crash dump -\n");
 }
 
-- 
1.8.3.1



[PATCH net-next v2 2/4] bnx2x: Populate database for Idlechk tests.

2020-07-03 Thread Sudarsana Reddy Kalluru
This patch populates the database of idlecck tests (registers and
predicates) used in the idlechk dump implementation.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
Reported-by: kernel test robot 
---
 drivers/net/ethernet/broadcom/bnx2x/Makefile   |2 +-
 .../net/ethernet/broadcom/bnx2x/bnx2x_self_test.c  | 2922 
 2 files changed, 2923 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c

diff --git a/drivers/net/ethernet/broadcom/bnx2x/Makefile 
b/drivers/net/ethernet/broadcom/bnx2x/Makefile
index 9fdfaa2..2523cfc 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/Makefile
+++ b/drivers/net/ethernet/broadcom/bnx2x/Makefile
@@ -5,5 +5,5 @@
 
 obj-$(CONFIG_BNX2X) += bnx2x.o
 
-bnx2x-y := bnx2x_main.o bnx2x_link.o bnx2x_cmn.o bnx2x_ethtool.o bnx2x_stats.o 
bnx2x_dcb.o bnx2x_sp.o
+bnx2x-y := bnx2x_main.o bnx2x_link.o bnx2x_cmn.o bnx2x_ethtool.o bnx2x_stats.o 
bnx2x_dcb.o bnx2x_sp.o bnx2x_self_test.o
 bnx2x-$(CONFIG_BNX2X_SRIOV) += bnx2x_vfpf.o bnx2x_sriov.o
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c
new file mode 100644
index 000..93a7f7e
--- /dev/null
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c
@@ -0,0 +1,2922 @@
+// SPDX-License-Identifier: GPL-2.0
+#include 
+#include 
+#include "bnx2x.h"
+
+#define NA 0xCD
+
+#define IDLE_CHK_E10x01
+#define IDLE_CHK_E1H   0x02
+#define IDLE_CHK_E20x04
+#define IDLE_CHK_E3A0  0x08
+#define IDLE_CHK_E3B0  0x10
+
+#define IDLE_CHK_ERROR 1
+#define IDLE_CHK_ERROR_NO_TRAFFIC  2
+#define IDLE_CHK_WARNING   3
+
+#define MAX_FAIL_MSG 256
+
+/* statistics and error reporting */
+static int idle_chk_errors;
+
+/* struct for the argument list for a predicate in the self test databasei */
+struct st_pred_args {
+   u32 val1; /* value read from first register */
+   u32 val2; /* value read from second register, if applicable */
+   u32 imm1; /* 1st value in predicate condition, left-to-right */
+   u32 imm2; /* 2nd value in predicate condition, left-to-right */
+   u32 imm3; /* 3rd value in predicate condition, left-to-right */
+   u32 imm4; /* 4th value in predicate condition, left-to-right */
+};
+
+/*struct representing self test record - a single test*/
+struct st_record {
+   u8 chip_mask;
+   u8 macro;
+   u32 reg1;
+   u32 reg2;
+   u16 loop;
+   u16 incr;
+   int (*bnx2x_predicate)(struct st_pred_args *pred_args);
+   u32 reg3;
+   u8 severity;
+   char *fail_msg;
+   struct st_pred_args pred_args;
+};
+
+/* predicates for self test */
+static int peq(struct st_pred_args *args)
+{
+   return (args->val1 == args->imm1);
+}
+
+static int pneq(struct st_pred_args *args)
+{
+   return (args->val1 != args->imm1);
+}
+
+static int pand_neq(struct st_pred_args *args)
+{
+   return ((args->val1 & args->imm1) != args->imm2);
+}
+
+static int pand_neq_x2(struct st_pred_args *args)
+{
+   return (((args->val1 & args->imm1) != args->imm2) &&
+   ((args->val1 & args->imm3) != args->imm4));
+}
+
+static int pneq_err(struct st_pred_args *args)
+{
+   return ((args->val1 != args->imm1) && (idle_chk_errors > args->imm2));
+}
+
+static int pgt(struct st_pred_args *args)
+{
+   return (args->val1 > args->imm1);
+}
+
+static int pneq_r2(struct st_pred_args *args)
+{
+   return (args->val1 != args->val2);
+}
+
+static int plt_sub_r2(struct st_pred_args *args)
+{
+   return (args->val1 < (args->val2 - args->imm1));
+}
+
+static int pne_sub_r2(struct st_pred_args *args)
+{
+   return (args->val1 != (args->val2 - args->imm1));
+}
+
+static int prsh_and_neq(struct st_pred_args *args)
+{
+   return (((args->val1 >> args->imm1) & args->imm2) != args->imm3);
+}
+
+static int peq_neq_r2(struct st_pred_args *args)
+{
+   return ((args->val1 == args->imm1) && (args->val2 != args->imm2));
+}
+
+static int peq_neq_neq_r2(struct st_pred_args *args)
+{
+   return ((args->val1 == args->imm1) && (args->val2 != args->imm2) &&
+   (args->val2 != args->imm3));
+}
+
+/* struct holding the database of self test checks (registers and predicates) 
*/
+/* lines start from 2 since line 1 is heading in csv */
+#define ST_DB_LINES 468
+struct st_record st_database[ST_DB_LINES] = {
+/*line 2*/{(0x3), 1, 0x2114,
+   NA, 1, 0, pand_neq,
+   NA, IDLE_CHK_ERROR,
+   "PCIE: ucorr_err_status is not 0",
+   {NA, NA, 0x0FF010, 0, NA, NA} },
+
+/*line 3*/{(0x3), 1, 0x2114,
+   NA, 1, 0, pand_neq,
+   NA, IDLE_CHK_WARNING,
+   "PCIE: uc

[PATCH net-next v2 3/4] bnx2x: Add support for idlechk tests.

2020-07-03 Thread Sudarsana Reddy Kalluru
The patch adds driver implementation for performing the idlechk tests.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
Reported-by: kernel test robot 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h|  10 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |   7 +
 .../net/ethernet/broadcom/bnx2x/bnx2x_self_test.c  | 268 -
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c  |   2 +
 4 files changed, 277 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 4f5b2b8..dee61d9 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -1979,6 +1979,9 @@ struct bnx2x_func_init_params {
 
 #define skip_queue(bp, idx)(NO_FCOE(bp) && IS_FCOE_IDX(idx))
 
+/*self test*/
+int bnx2x_idle_chk(struct bnx2x *bp);
+
 /**
  * bnx2x_set_mac_one - configure a single MAC address
  *
@@ -2430,13 +2433,6 @@ void bnx2x_igu_clear_sb_gen(struct bnx2x *bp, u8 func, 
u8 idu_sb_id,
 #define HC_SEG_ACCESS_ATTN 4
 #define HC_SEG_ACCESS_NORM 0   /*Driver decision 0-1*/
 
-static const u32 dmae_reg_go_c[] = {
-   DMAE_REG_GO_C0, DMAE_REG_GO_C1, DMAE_REG_GO_C2, DMAE_REG_GO_C3,
-   DMAE_REG_GO_C4, DMAE_REG_GO_C5, DMAE_REG_GO_C6, DMAE_REG_GO_C7,
-   DMAE_REG_GO_C8, DMAE_REG_GO_C9, DMAE_REG_GO_C10, DMAE_REG_GO_C11,
-   DMAE_REG_GO_C12, DMAE_REG_GO_C13, DMAE_REG_GO_C14, DMAE_REG_GO_C15
-};
-
 void bnx2x_set_ethtool_ops(struct bnx2x *bp, struct net_device *netdev);
 void bnx2x_notify_link_changed(struct bnx2x *bp);
 
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index db5107e7..06dfb90 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -276,6 +276,13 @@ enum bnx2x_board_type {
 
 MODULE_DEVICE_TABLE(pci, bnx2x_pci_tbl);
 
+const u32 dmae_reg_go_c[] = {
+   DMAE_REG_GO_C0, DMAE_REG_GO_C1, DMAE_REG_GO_C2, DMAE_REG_GO_C3,
+   DMAE_REG_GO_C4, DMAE_REG_GO_C5, DMAE_REG_GO_C6, DMAE_REG_GO_C7,
+   DMAE_REG_GO_C8, DMAE_REG_GO_C9, DMAE_REG_GO_C10, DMAE_REG_GO_C11,
+   DMAE_REG_GO_C12, DMAE_REG_GO_C13, DMAE_REG_GO_C14, DMAE_REG_GO_C15
+};
+
 /* Global resources for unloading a previously loaded device */
 #define BNX2X_PREV_WAIT_NEEDED 1
 static DEFINE_SEMAPHORE(bnx2x_prev_sem);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c
index 93a7f7e..32a2295 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c
@@ -18,7 +18,11 @@
 #define MAX_FAIL_MSG 256
 
 /* statistics and error reporting */
-static int idle_chk_errors;
+static int idle_chk_errors, idle_chk_warnings;
+
+/* masks for all chip types */
+static int is_e1, is_e1h, is_e2, is_e3a0, is_e3b0;
+
 
 /* struct for the argument list for a predicate in the self test databasei */
 struct st_pred_args {
@@ -30,7 +34,7 @@ struct st_pred_args {
u32 imm4; /* 4th value in predicate condition, left-to-right */
 };
 
-/*struct representing self test record - a single test*/
+/* struct representing self test record - a single test */
 struct st_record {
u8 chip_mask;
u8 macro;
@@ -111,7 +115,7 @@ static int peq_neq_neq_r2(struct st_pred_args *args)
 /* struct holding the database of self test checks (registers and predicates) 
*/
 /* lines start from 2 since line 1 is heading in csv */
 #define ST_DB_LINES 468
-struct st_record st_database[ST_DB_LINES] = {
+static struct st_record st_database[ST_DB_LINES] = {
 /*line 2*/{(0x3), 1, 0x2114,
NA, 1, 0, pand_neq,
NA, IDLE_CHK_ERROR,
@@ -2920,3 +2924,261 @@ struct st_record st_database[ST_DB_LINES] = {
"NIG: PBF IF5 FIFO is not empty",
{NA, NA, 1, NA, NA, NA} },
 };
+
+/* handle self test fails according to severity and type */
+static void bnx2x_self_test_log(struct bnx2x *bp, u8 severity, char *message)
+{
+   switch (severity) {
+   case IDLE_CHK_ERROR:
+   BNX2X_ERR("ERROR %s", message);
+   idle_chk_errors++;
+   break;
+   case IDLE_CHK_ERROR_NO_TRAFFIC:
+   DP(NETIF_MSG_HW, "INFO %s", message);
+   break;
+   case IDLE_CHK_WARNING:
+   DP(NETIF_MSG_HW, "WARNING %s", message);
+   idle_chk_warnings++;
+   break;
+   }
+}
+
+/* specific test for QM rd/wr pointers and rd/wr banks */
+static void bnx2x_idle_chk6(struct bnx2x *bp,
+   struct st_record *rec, char *message)
+{
+   u32 rd_ptr, wr_ptr, rd_bank, wr_bank;
+   int i;
+
+   for (i = 0; i < rec->loop; i++) {
+   /* read regs */
+   rec->pred_args.val1 =
+   REG_RD(bp, rec-&g

[PATCH net-next v2 0/4] bnx2x: Perform IdleChk dump.

2020-07-03 Thread Sudarsana Reddy Kalluru
Idlechk test verifies that the chip is in idle state. If there are any
errors, Idlechk dump would capture the same. This would help in debugging
the device related issues.
The patch series adds driver support for dumping IdleChk data during the
debug dump collection.
Patch (1) adds register definitions required in this implementation.
Patch (2) adds database of self test checks (registers and predicates).
Patch (3) adds the implementation for Idlechk test.
Patch (4) adds driver changes to invoke Idlechk implementation.


Changes from previous version:
---
v2: Addressed issues reported by kernel test robot.


Please consider applying to net-next tree.

Sudarsana Reddy Kalluru (4):
  bnx2x: Add Idlechk related register definitions.
  bnx2x: Populate database for Idlechk tests.
  bnx2x: Add support for idlechk tests.
  bnx2x: Perform Idlechk dump during the debug collection.

 drivers/net/ethernet/broadcom/bnx2x/Makefile   |2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h|   10 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |   16 +
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h|   78 +-
 .../net/ethernet/broadcom/bnx2x/bnx2x_self_test.c  | 3184 
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c  |2 +
 6 files changed, 3282 insertions(+), 10 deletions(-)
 create mode 100644 drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c

-- 
1.8.3.1



RE: [EXT] Re: [PATCH net 1/1] qed: Populate nvm-file attributes while reading nvm config partition.

2020-07-02 Thread Sudarsana Reddy Kalluru


> -Original Message-
> From: Jakub Kicinski 
> Sent: Thursday, July 2, 2020 10:10 PM
> To: Sudarsana Reddy Kalluru 
> Cc: da...@davemloft.net; netdev@vger.kernel.org; Ariel Elior
> ; Igor Russkikh ; Michal
> Kalderon 
> Subject: [EXT] Re: [PATCH net 1/1] qed: Populate nvm-file attributes while
> reading nvm config partition.
> 
> External Email
> 
> --
> On Thu, 2 Jul 2020 20:14:35 +0530 Sudarsana Reddy Kalluru wrote:
> > NVM config file address will be modified when the MBI image is upgraded.
> > Driver would return stale config values if user reads the nvm-config
> > (via ethtool -d) in this state. The fix is to re-populate nvm
> > attribute info while reading the nvm config values/partition.
> >
> > Signed-off-by: Sudarsana Reddy Kalluru 
> > Signed-off-by: Igor Russkikh 
> 
> Could you provide a Fixes tag?

Thanks for your review. Will add the fixes tag.


[PATCH net 1/1] qed: Populate nvm-file attributes while reading nvm config partition.

2020-07-02 Thread Sudarsana Reddy Kalluru
NVM config file address will be modified when the MBI image is upgraded.
Driver would return stale config values if user reads the nvm-config
(via ethtool -d) in this state. The fix is to re-populate nvm attribute
info while reading the nvm config values/partition.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
---
 drivers/net/ethernet/qlogic/qed/qed_debug.c |  4 
 drivers/net/ethernet/qlogic/qed/qed_dev.c   | 12 +++-
 drivers/net/ethernet/qlogic/qed/qed_mcp.c   |  7 +++
 drivers/net/ethernet/qlogic/qed/qed_mcp.h   |  7 +++
 4 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c 
b/drivers/net/ethernet/qlogic/qed/qed_debug.c
index f4eebaa..a1270fd 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_debug.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c
@@ -7930,6 +7930,10 @@ int qed_dbg_all_data(struct qed_dev *cdev, void *buffer)
DP_ERR(cdev, "qed_dbg_mcp_trace failed. rc = %d\n", rc);
}
 
+   /* Re-populate nvm attribute info */
+   qed_mcp_nvm_info_free(p_hwfn);
+   qed_mcp_nvm_info_populate(p_hwfn);
+
/* nvm cfg1 */
rc = qed_dbg_nvm_image(cdev,
   (u8 *)buffer + offset +
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 38a65b9..0331cce 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -4461,12 +4461,6 @@ static int qed_get_dev_info(struct qed_hwfn *p_hwfn, 
struct qed_ptt *p_ptt)
return 0;
 }
 
-static void qed_nvm_info_free(struct qed_hwfn *p_hwfn)
-{
-   kfree(p_hwfn->nvm_info.image_att);
-   p_hwfn->nvm_info.image_att = NULL;
-}
-
 static int qed_hw_prepare_single(struct qed_hwfn *p_hwfn,
 void __iomem *p_regview,
 void __iomem *p_doorbells,
@@ -4551,7 +4545,7 @@ static int qed_hw_prepare_single(struct qed_hwfn *p_hwfn,
return rc;
 err3:
if (IS_LEAD_HWFN(p_hwfn))
-   qed_nvm_info_free(p_hwfn);
+   qed_mcp_nvm_info_free(p_hwfn);
 err2:
if (IS_LEAD_HWFN(p_hwfn))
qed_iov_free_hw_info(p_hwfn->cdev);
@@ -4612,7 +4606,7 @@ int qed_hw_prepare(struct qed_dev *cdev,
if (rc) {
if (IS_PF(cdev)) {
qed_init_free(p_hwfn);
-   qed_nvm_info_free(p_hwfn);
+   qed_mcp_nvm_info_free(p_hwfn);
qed_mcp_free(p_hwfn);
qed_hw_hwfn_free(p_hwfn);
}
@@ -4646,7 +4640,7 @@ void qed_hw_remove(struct qed_dev *cdev)
 
qed_iov_free_hw_info(cdev);
 
-   qed_nvm_info_free(p_hwfn);
+   qed_mcp_nvm_info_free(p_hwfn);
 }
 
 static void qed_chain_free_next_ptr(struct qed_dev *cdev,
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index 280527c..99548d5 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -3151,6 +3151,13 @@ int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn)
return rc;
 }
 
+void qed_mcp_nvm_info_free(struct qed_hwfn *p_hwfn)
+{
+   kfree(p_hwfn->nvm_info.image_att);
+   p_hwfn->nvm_info.image_att = NULL;
+   p_hwfn->nvm_info.valid = false;
+}
+
 int
 qed_mcp_get_nvm_image_att(struct qed_hwfn *p_hwfn,
  enum qed_nvm_images image_id,
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.h 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
index 9c4c276..e382973 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
@@ -1193,6 +1193,13 @@ void qed_mcp_resc_lock_default_init(struct 
qed_resc_lock_params *p_lock,
 int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn);
 
 /**
+ * @brief Delete nvm info shadow in the given hardware function
+ *
+ * @param p_hwfn
+ */
+void qed_mcp_nvm_info_free(struct qed_hwfn *p_hwfn);
+
+/**
  * @brief Get the engine affinity configuration.
  *
  * @param p_hwfn
-- 
1.8.3.1



[PATCH net-next 4/4] bnx2x: Perform Idlechk dump during the debug collection.

2020-07-02 Thread Sudarsana Reddy Kalluru
The patch adds driver changes to perform Idlechk dump during the debug
data collection.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index db5107e7..e89e7a8 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -1169,9 +1169,18 @@ void bnx2x_panic_dump(struct bnx2x *bp, bool disable_int)
}
 #endif
if (IS_PF(bp)) {
+   int tmp_msg_en = bp->msg_enable;
+
bnx2x_fw_dump(bp);
+   bp->msg_enable |= NETIF_MSG_HW;
+   BNX2X_ERR("Idle check (1st round) --\n");
+   bnx2x_idle_chk(bp);
+   BNX2X_ERR("Idle check (2nd round) --\n");
+   bnx2x_idle_chk(bp);
+   bp->msg_enable = tmp_msg_en;
bnx2x_mc_assert(bp);
}
+
BNX2X_ERR("end crash dump -\n");
 }
 
-- 
1.8.3.1



[PATCH net-next 2/4] bnx2x: Populate database for Idlechk tests.

2020-07-02 Thread Sudarsana Reddy Kalluru
This patch populates the database of idlecck tests (registers and
predicates) used in the idlechk dump implementation.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
---
 drivers/net/ethernet/broadcom/bnx2x/Makefile   |2 +-
 .../net/ethernet/broadcom/bnx2x/bnx2x_self_test.c  | 2922 
 2 files changed, 2923 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c

diff --git a/drivers/net/ethernet/broadcom/bnx2x/Makefile 
b/drivers/net/ethernet/broadcom/bnx2x/Makefile
index 9fdfaa2..2523cfc 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/Makefile
+++ b/drivers/net/ethernet/broadcom/bnx2x/Makefile
@@ -5,5 +5,5 @@
 
 obj-$(CONFIG_BNX2X) += bnx2x.o
 
-bnx2x-y := bnx2x_main.o bnx2x_link.o bnx2x_cmn.o bnx2x_ethtool.o bnx2x_stats.o 
bnx2x_dcb.o bnx2x_sp.o
+bnx2x-y := bnx2x_main.o bnx2x_link.o bnx2x_cmn.o bnx2x_ethtool.o bnx2x_stats.o 
bnx2x_dcb.o bnx2x_sp.o bnx2x_self_test.o
 bnx2x-$(CONFIG_BNX2X_SRIOV) += bnx2x_vfpf.o bnx2x_sriov.o
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c
new file mode 100644
index 000..ea71fd5
--- /dev/null
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c
@@ -0,0 +1,2922 @@
+// SPDX-License-Identifier: GPL-2.0
+#include 
+#include 
+#include "bnx2x.h"
+
+#define NA 0xCD
+
+#define IDLE_CHK_E10x01
+#define IDLE_CHK_E1H   0x02
+#define IDLE_CHK_E20x04
+#define IDLE_CHK_E3A0  0x08
+#define IDLE_CHK_E3B0  0x10
+
+#define IDLE_CHK_ERROR 1
+#define IDLE_CHK_ERROR_NO_TRAFFIC  2
+#define IDLE_CHK_WARNING   3
+
+#define MAX_FAIL_MSG 256
+
+/* statistics and error reporting */
+static int idle_chk_errors;
+
+/* struct for the argument list for a predicate in the self test databasei */
+struct st_pred_args {
+   u32 val1; /* value read from first register */
+   u32 val2; /* value read from second register, if applicable */
+   u32 imm1; /* 1st value in predicate condition, left-to-right */
+   u32 imm2; /* 2nd value in predicate condition, left-to-right */
+   u32 imm3; /* 3rd value in predicate condition, left-to-right */
+   u32 imm4; /* 4th value in predicate condition, left-to-right */
+};
+
+/*struct representing self test record - a single test*/
+struct st_record {
+   u8 chip_mask;
+   u8 macro;
+   u32 reg1;
+   u32 reg2;
+   u16 loop;
+   u16 incr;
+   int (*predicate)(struct st_pred_args *pred_args);
+   u32 reg3;
+   u8 severity;
+   char *fail_msg;
+   struct st_pred_args pred_args;
+};
+
+/* predicates for self test */
+static int peq(struct st_pred_args *args)
+{
+   return (args->val1 == args->imm1);
+}
+
+static int pneq(struct st_pred_args *args)
+{
+   return (args->val1 != args->imm1);
+}
+
+static int pand_neq(struct st_pred_args *args)
+{
+   return ((args->val1 & args->imm1) != args->imm2);
+}
+
+static int pand_neq_x2(struct st_pred_args *args)
+{
+   return (((args->val1 & args->imm1) != args->imm2) &&
+   ((args->val1 & args->imm3) != args->imm4));
+}
+
+static int pneq_err(struct st_pred_args *args)
+{
+   return ((args->val1 != args->imm1) && (idle_chk_errors > args->imm2));
+}
+
+static int pgt(struct st_pred_args *args)
+{
+   return (args->val1 > args->imm1);
+}
+
+static int pneq_r2(struct st_pred_args *args)
+{
+   return (args->val1 != args->val2);
+}
+
+static int plt_sub_r2(struct st_pred_args *args)
+{
+   return (args->val1 < (args->val2 - args->imm1));
+}
+
+static int pne_sub_r2(struct st_pred_args *args)
+{
+   return (args->val1 != (args->val2 - args->imm1));
+}
+
+static int prsh_and_neq(struct st_pred_args *args)
+{
+   return (((args->val1 >> args->imm1) & args->imm2) != args->imm3);
+}
+
+static int peq_neq_r2(struct st_pred_args *args)
+{
+   return ((args->val1 == args->imm1) && (args->val2 != args->imm2));
+}
+
+static int peq_neq_neq_r2(struct st_pred_args *args)
+{
+   return ((args->val1 == args->imm1) && (args->val2 != args->imm2) &&
+   (args->val2 != args->imm3));
+}
+
+/* struct holding the database of self test checks (registers and predicates) 
*/
+/* lines start from 2 since line 1 is heading in csv */
+#define ST_DB_LINES 468
+struct st_record st_database[ST_DB_LINES] = {
+/*line 2*/{(0x3), 1, 0x2114,
+   NA, 1, 0, pand_neq,
+   NA, IDLE_CHK_ERROR,
+   "PCIE: ucorr_err_status is not 0",
+   {NA, NA, 0x0FF010, 0, NA, NA} },
+
+/*line 3*/{(0x3), 1, 0x2114,
+   NA, 1, 0, pand_neq,
+   NA, IDLE_CHK_WARNING,
+   "PCIE: ucorr_err_status - Unsupported request erro

[PATCH net-next 1/4] bnx2x: Add Idlechk related register definitions.

2020-07-02 Thread Sudarsana Reddy Kalluru
The patch adds register definitions required for Idlechk implementation.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h | 78 -
 1 file changed, 76 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
index a43dea2..bfc0e45 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
@@ -7639,6 +7639,82 @@
(0x80 | ((_type)&0xf << 3) | ((CDU_CRC8(_cid, _region, _type)) & 0x7))
 #define CDU_RSRVD_INVALIDATE_CONTEXT_VALUE(_val) ((_val) & ~0x80)
 
+/* IdleChk registers */
+#define PXP_REG_HST_VF_DISABLED_ERROR_VALID 0x1030bc
+#define PXP_REG_HST_VF_DISABLED_ERROR_DATA  0x1030b8
+#define PXP_REG_HST_PER_VIOLATION_VALID 
0x1030e0
+#define PXP_REG_HST_INCORRECT_ACCESS_VALID  0x1030cc
+#define PXP2_REG_RD_CPL_ERR_DETAILS 0x120778
+#define PXP2_REG_RD_CPL_ERR_DETAILS20x12077c
+#define PXP2_REG_RQ_GARB0x120748
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q00x15c1bc
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q10x15c1c0
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q20x15c1c4
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q30x15c1c8
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q40x15c1cc
+#define PBF_REG_DISABLE_NEW_TASK_PROC_Q50x15c1d0
+#define PBF_REG_CREDIT_Q2   0x140344
+#define PBF_REG_CREDIT_Q3   0x140348
+#define PBF_REG_CREDIT_Q4   0x14034c
+#define PBF_REG_CREDIT_Q5   0x140350
+#define PBF_REG_INIT_CRD_Q2 0x15c238
+#define PBF_REG_INIT_CRD_Q3 0x15c23c
+#define PBF_REG_INIT_CRD_Q4 0x15c240
+#define PBF_REG_INIT_CRD_Q5 0x15c244
+#define PBF_REG_TASK_CNT_Q0 0x140374
+#define PBF_REG_TASK_CNT_Q1 0x140378
+#define PBF_REG_TASK_CNT_Q2 0x14037c
+#define PBF_REG_TASK_CNT_Q3 0x140380
+#define PBF_REG_TASK_CNT_Q4 0x140384
+#define PBF_REG_TASK_CNT_Q5 0x140388
+#define PBF_REG_TASK_CNT_LB_Q   0x140370
+#define QM_REG_BYTECRD0 
0x16e6fc
+#define QM_REG_BYTECRD1 
0x16e700
+#define QM_REG_BYTECRD2 
0x16e704
+#define QM_REG_BYTECRD3 
0x16e7ac
+#define QM_REG_BYTECRD4 
0x16e7b0
+#define QM_REG_BYTECRD5 
0x16e7b4
+#define QM_REG_BYTECRD6 
0x16e7b8
+#define QM_REG_BYTECRDCMDQ_00x16e6e8
+#define QM_REG_BYTECRDERRREG0x16e708
+#define MISC_REG_GRC_TIMEOUT_ATTN_FULL_FID  0xa714
+#define QM_REG_VOQCREDIT_2  0x1682d8
+#define QM_REG_VOQCREDIT_3  0x1682dc
+#define QM_REG_VOQCREDIT_5  0x1682e4
+#define QM_REG_VOQCREDIT_6  0x1682e8
+#define QM_REG_VOQINITCREDIT_3  0x16806c
+#define QM_REG_VOQINITCREDIT_6  0x168078
+#define QM_REG_FWVOQ0TOHWVOQ0x16e7bc
+#define QM_REG_FWVOQ1TOHWVOQ0x16e7c0
+#define QM_REG_FWVOQ2TOHWVOQ0x16e7c4
+#define QM_REG_FWVOQ3TOHWVOQ0x16e7c8
+#define QM_REG_FWVOQ4TOHWVOQ0x16e7cc
+#define QM_REG_FWVOQ5TOHWVOQ0x16e7d0
+#define QM_REG_FWVOQ6TOHWVOQ0x16e7d4
+#define QM_REG_FWVOQ7TOHWVOQ0x16e7d8
+#define NIG_REG_INGRESS_EOP_PORT0_EMPTY 0x104ec
+#define NIG_REG_INGRESS_EOP_PORT1_EMPTY 0x104f8
+#define NIG_REG_INGRESS_RMP0_DSCR_EMPTY 0x10530
+#define NIG_REG_INGRESS_RMP1_DSCR_EMPTY   

[PATCH net-next 0/4] bnx2x: Perform IdleChk dump.

2020-07-02 Thread Sudarsana Reddy Kalluru
Idlechk test verifies that the chip is in idle state. If there are any
errors, Idlechk dump would capture the same. This would help in debugging
the device related issues.
The patch series adds driver support for dumping IdleChk data during the
debug dump collection.
Patch (1) adds register definitions required in this implementation.
Patch (2) adds database of self test checks (registers and predicates).
Patch (3) adds the implementation for Idlechk test.
Patch (4) adds driver changes to invoke Idlechk implementation.


Sudarsana Reddy Kalluru (4):
  bnx2x: Add Idlechk related register definitions.
  bnx2x: Populate database for Idlechk tests.
  bnx2x: Add support for idlechk tests.
  bnx2x: Perform Idlechk dump during the debug collection.

 drivers/net/ethernet/broadcom/bnx2x/Makefile   |2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h|3 +
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c   |9 +
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h|   78 +-
 .../net/ethernet/broadcom/bnx2x/bnx2x_self_test.c  | 3184 
 5 files changed, 3273 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c

-- 
1.8.3.1



[PATCH net-next 3/4] bnx2x: Add support for idlechk tests.

2020-07-02 Thread Sudarsana Reddy Kalluru
The patch adds driver implementation for performing the idlechk tests.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h|   3 +
 .../net/ethernet/broadcom/bnx2x/bnx2x_self_test.c  | 266 -
 2 files changed, 267 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 4f5b2b8..3a1af3c 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -1979,6 +1979,9 @@ struct bnx2x_func_init_params {
 
 #define skip_queue(bp, idx)(NO_FCOE(bp) && IS_FCOE_IDX(idx))
 
+/*self test*/
+int bnx2x_idle_chk(struct bnx2x *bp);
+
 /**
  * bnx2x_set_mac_one - configure a single MAC address
  *
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c
index ea71fd5..4f218881 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_self_test.c
@@ -18,7 +18,11 @@
 #define MAX_FAIL_MSG 256
 
 /* statistics and error reporting */
-static int idle_chk_errors;
+static int idle_chk_errors, idle_chk_warnings;
+
+/* masks for all chip types */
+static int is_e1, is_e1h, is_e2, is_e3a0, is_e3b0;
+
 
 /* struct for the argument list for a predicate in the self test databasei */
 struct st_pred_args {
@@ -30,7 +34,7 @@ struct st_pred_args {
u32 imm4; /* 4th value in predicate condition, left-to-right */
 };
 
-/*struct representing self test record - a single test*/
+/* struct representing self test record - a single test */
 struct st_record {
u8 chip_mask;
u8 macro;
@@ -2920,3 +2924,261 @@ struct st_record st_database[ST_DB_LINES] = {
"NIG: PBF IF5 FIFO is not empty",
{NA, NA, 1, NA, NA, NA} },
 };
+
+/* handle self test fails according to severity and type */
+static void bnx2x_self_test_log(struct bnx2x *bp, u8 severity, char *message)
+{
+   switch (severity) {
+   case IDLE_CHK_ERROR:
+   BNX2X_ERR("ERROR %s", message);
+   idle_chk_errors++;
+   break;
+   case IDLE_CHK_ERROR_NO_TRAFFIC:
+   DP(NETIF_MSG_HW, "INFO %s", message);
+   break;
+   case IDLE_CHK_WARNING:
+   DP(NETIF_MSG_HW, "WARNING %s", message);
+   idle_chk_warnings++;
+   break;
+   }
+}
+
+/* specific test for QM rd/wr pointers and rd/wr banks */
+static void bnx2x_idle_chk6(struct bnx2x *bp,
+   struct st_record *rec, char *message)
+{
+   u32 rd_ptr, wr_ptr, rd_bank, wr_bank;
+   int i;
+
+   for (i = 0; i < rec->loop; i++) {
+   /* read regs */
+   rec->pred_args.val1 =
+   REG_RD(bp, rec->reg1 + i * rec->incr);
+   rec->pred_args.val2 =
+   REG_RD(bp, rec->reg1 + i * rec->incr + 4);
+
+   /* calc read and write pointers */
+   rd_ptr = ((rec->pred_args.val1 & 0x3FC0) >> 6);
+   wr_ptr = rec->pred_args.val1 & 0xC000) >> 30) & 0x3) |
+   ((rec->pred_args.val2 & 0x3F) << 2));
+
+   /* perfrom pointer test */
+   if (rd_ptr != wr_ptr) {
+   snprintf(message, MAX_FAIL_MSG,
+"QM: PTRTBL entry %d- rd_ptr is not equal to 
wr_ptr. Values are 0x%x and 0x%x\n",
+i, rd_ptr, wr_ptr);
+   bnx2x_self_test_log(bp, rec->severity, message);
+   }
+
+   /* calculate read and write banks */
+   rd_bank = ((rec->pred_args.val1 & 0x30) >> 4);
+   wr_bank = (rec->pred_args.val1 & 0x03);
+
+   /* perform bank test */
+   if (rd_bank != wr_bank) {
+   snprintf(message, MAX_FAIL_MSG,
+"QM: PTRTBL entry %d - rd_bank is not equal to 
wr_bank. Values are 0x%x 0x%x\n",
+i, rd_bank, wr_bank);
+   bnx2x_self_test_log(bp, rec->severity, message);
+   }
+   }
+}
+
+/* specific test for cfc info ram and cid cam */
+static void bnx2x_idle_chk7(struct bnx2x *bp,
+   struct st_record *rec, char *message)
+{
+   int i;
+
+   /* iterate through lcids */
+   for (i = 0; i < rec->loop; i++) {
+   /* make sure cam entry is valid (bit 0) */
+   if ((REG_RD(bp, (rec->reg2 + i * 4)) & 0x1) != 0x1)
+   continue;
+
+   /* get connection type (multiple reads due to widebus) */
+   REG_RD(bp, (rec->reg1 + i * 

RE: [EXT] [PATCH v1] bnx2x: use generic power management

2020-06-26 Thread Sudarsana Reddy Kalluru

> -Original Message-
> From: Igor Russkikh 
> Sent: Thursday, June 25, 2020 10:16 PM
> To: Vaibhav Gupta ; Bjorn Helgaas
> ; Bjorn Helgaas ;
> bj...@helgaas.com; Vaibhav Gupta ; David S.
> Miller ; Jakub Kicinski ; Ariel Elior
> ; Sudarsana Reddy Kalluru ; GR-
> everest-linux-l2 
> Cc: netdev@vger.kernel.org; linux-ker...@vger.kernel.org; linux-kernel-
> ment...@lists.linuxfoundation.org; sk...@linuxfoundation.org
> Subject: Re: [EXT] [PATCH v1] bnx2x: use generic power management
> 
> 
> 
> On 24/06/2020 8:51 pm, Vaibhav Gupta wrote:
> > External Email
> >
> > --
> > With legacy PM, drivers themselves were responsible for managing the
> > device's power states and takes care of register states.
> >
> > After upgrading to the generic structure, PCI core will take care of
> > required tasks and drivers should do only device-specific operations.
> >
> > The driver was also calling bnx2x_set_power_state() to set the power
> > state of the device by changing the device's registers' value. It is
> > no more needed.
> >
> > Compile-tested only.
> >
> > Signed-off-by: Vaibhav Gupta 
> > ---
> >  drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c  | 15 ++-
> > drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h  |  4 +---
> > drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |  3 +--
> >  3 files changed, 8 insertions(+), 14 deletions(-)
> 
> Acked-by: Igor Russkikh 
> 
> Sudarsana, could you please give it a short sanity test and report back?
> 
> Thanks,
>   Igor

I have run the basic sanity test with these changes in the driver, didn’t see 
any issues.

Thanks,
Sudarsana


[PATCH net-next 1/1] qedr: Avoid DB recover entry deletion when device is not active.

2020-04-30 Thread Sudarsana Reddy Kalluru
The doorbell (DB) recovery entries gets deleted by the QED driver when
QEDR device transition to non-active or dead state (e.g., during the
AER recovery phase). The patch adds driver changes to skip deleting
DB recovery entries from QEDR when the device is in non-active state.

Fixes: 731815e720ae ("qede: Add support for handling the pcie errors.")
Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Igor Russkikh 
---
 drivers/infiniband/hw/qedr/verbs.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/infiniband/hw/qedr/verbs.c 
b/drivers/infiniband/hw/qedr/verbs.c
index a5bd3ad..7e10f3b 100644
--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -672,6 +672,12 @@ static void qedr_db_recovery_del(struct qedr_dev *dev,
 void __iomem *db_addr,
 void *db_data)
 {
+   if (QEDR_DEAD(dev)) {
+   DP_VERBOSE(dev, QEDR_MSG_FAIL,
+  "avoiding db rec since device is dead\n");
+   return 0;
+   }
+
if (!db_data) {
DP_DEBUG(dev, QEDR_MSG_INIT, "avoiding db rec since old lib\n");
return;
-- 
1.8.3.1



[PATCH net-next 0/2] qed* Fix series.

2019-09-11 Thread Sudarsana Reddy Kalluru
The patch series addresses couple of issues in the recent commits.
Patch (1) populates the actual dump-size of config attribute instead of
providing a fixed size value.
Patch(2) updates frame format of flash config buffer as required by
management FW (MFW).

Please consider applying it to net-next.

Sudarsana Reddy Kalluru (2):
  qed*: Fix size of config attribute dump.
  qed: Fix Config attribute frame format.

 drivers/net/ethernet/qlogic/qed/qed_main.c  | 47 +++--
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 14 
 include/linux/qed/qed_if.h  |  8 +
 3 files changed, 53 insertions(+), 16 deletions(-)

-- 
1.8.3.1



[PATCH net-next 1/2] qed*: Fix size of config attribute dump.

2019-09-11 Thread Sudarsana Reddy Kalluru
Driver currently returns max-buf-size as size of the config attribute.
This patch incorporates changes to read this value from MFW (if available)
and provide it to the user. Also did a trivial clean up in this path.

Fixes: d44a3ced7023 ("qede: Add support for reading the config id attributes.")
Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_main.c  | 26 +
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 14 +++--
 include/linux/qed/qed_if.h  |  8 
 3 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index ac1511a8..38c0ec3 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -2300,6 +2300,31 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, 
const u8 **data)
return rc;
 }
 
+#define QED_MAX_NVM_BUF_LEN32
+static int qed_nvm_flash_cfg_len(struct qed_dev *cdev, u32 cmd)
+{
+   struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
+   u8 buf[QED_MAX_NVM_BUF_LEN];
+   struct qed_ptt *ptt;
+   u32 len;
+   int rc;
+
+   ptt = qed_ptt_acquire(hwfn);
+   if (!ptt)
+   return QED_MAX_NVM_BUF_LEN;
+
+   rc = qed_mcp_nvm_get_cfg(hwfn, ptt, cmd, 0, QED_NVM_CFG_GET_FLAGS, buf,
+&len);
+   if (rc || !len) {
+   DP_ERR(cdev, "Error %d reading %d\n", rc, cmd);
+   len = QED_MAX_NVM_BUF_LEN;
+   }
+
+   qed_ptt_release(hwfn, ptt);
+
+   return len;
+}
+
 static int qed_nvm_flash_cfg_read(struct qed_dev *cdev, u8 **data,
  u32 cmd, u32 entity_id)
 {
@@ -2657,6 +2682,7 @@ static u8 qed_get_affin_hwfn_idx(struct qed_dev *cdev)
.read_module_eeprom = &qed_read_module_eeprom,
.get_affin_hwfn_idx = &qed_get_affin_hwfn_idx,
.read_nvm_cfg = &qed_nvm_flash_cfg_read,
+   .read_nvm_cfg_len = &qed_nvm_flash_cfg_len,
.set_grc_config = &qed_set_grc_config,
 };
 
diff --git a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c 
b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
index ec27a43..8a426af 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
@@ -49,7 +49,6 @@
 
 #define QEDE_SELFTEST_POLL_COUNT 100
 #define QEDE_DUMP_VERSION  0x1
-#define QEDE_DUMP_NVM_BUF_LEN  32
 #define QEDE_DUMP_NVM_ARG_COUNT2
 
 static const struct {
@@ -2026,7 +2025,8 @@ static int qede_get_dump_flag(struct net_device *dev,
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;
+   dump->len = edev->ops->common->read_nvm_cfg_len(edev->cdev,
+   edev->dump_info.args[0]);
break;
case QEDE_DUMP_CMD_GRCDUMP:
dump->flag = QEDE_DUMP_CMD_GRCDUMP;
@@ -2051,9 +2051,8 @@ static int qede_get_dump_data(struct net_device *dev,
 
if (!edev->ops || !edev->ops->common) {
DP_ERR(edev, "Edev ops not populated\n");
-   edev->dump_info.cmd = QEDE_DUMP_CMD_NONE;
-   edev->dump_info.num_args = 0;
-   return -EINVAL;
+   rc = -EINVAL;
+   goto err;
}
 
switch (edev->dump_info.cmd) {
@@ -2062,7 +2061,8 @@ static int qede_get_dump_data(struct net_device *dev,
DP_ERR(edev, "Arg count = %d required = %d\n",
   edev->dump_info.num_args,
   QEDE_DUMP_NVM_ARG_COUNT);
-   return -EINVAL;
+   rc = -EINVAL;
+   goto err;
}
rc =  edev->ops->common->read_nvm_cfg(edev->cdev, (u8 **)&buf,
  edev->dump_info.args[0],
@@ -2078,8 +2078,10 @@ static int qede_get_dump_data(struct net_device *dev,
break;
}
 
+err:
edev->dump_info.cmd = QEDE_DUMP_CMD_NONE;
edev->dump_info.num_args = 0;
+   memset(edev->dump_info.args, 0, sizeof(edev->dump_info.args));
 
return rc;
 }
diff --git a/include/linux/qed/qed_if.h b/include/linux/qed/qed_if.h
index e354638..b5db1ee 100644
--- a/include/linux/qed/qed_if.h
+++ b/include/linux/qed/qed_if.h
@@ -1143,6 +1143,14 @@ struct qed_common_ops {
  */
int (*read_nvm_cfg)(struct qed_dev *cdev, u8 **buf, u32 cmd,
u32 entity_id);
+/**
+ * @brief read_nvm_cfg - Read NVM config attribute value.
+ * @param cdev
+ * @param cmd - NVM CFG command id
+ *
+ * @return config 

[PATCH net-next 2/2] qed: Fix Config attribute frame format.

2019-09-11 Thread Sudarsana Reddy Kalluru
MFW associates the entity id to a config attribute instead of assigning
one entity id for all the config attributes.
This patch incorporates driver changes to link entity id to a config id
attribute.

Fixes: 0dabbe1bb3a4 ("qed: Add driver API for flashing the config attributes.")
Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_main.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 38c0ec3..2ce7009 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -2240,12 +2240,13 @@ static int qed_nvm_flash_image_validate(struct qed_dev 
*cdev,
 /* Binary file format -
  * /--\
  * 0B  |   0x5 [command index]|
- * 4B  | Entity ID | Reserved|  Number of config attributes   |
- * 8B  | Config ID   | Length| Value  |
+ * 4B  | Number of config attributes |  Reserved  |
+ * 4B  | Config ID   | Entity ID  | Length|
+ * 4B  | Value|
  * |  |
  * \--/
- * There can be several cfg_id-Length-Value sets as specified by 'Number 
of...'.
- * Entity ID - A non zero entity value for which the config need to be updated.
+ * There can be several cfg_id-entity_id-Length-Value sets as specified by
+ * 'Number of config attributes'.
  *
  * The API parses config attributes from the user provided buffer and flashes
  * them to the respective NVM path using Management FW inerface.
@@ -2265,18 +2266,17 @@ static int qed_nvm_flash_cfg_write(struct qed_dev 
*cdev, const u8 **data)
 
/* NVM CFG ID attribute header */
*data += 4;
-   entity_id = **data;
-   *data += 2;
count = *((u16 *)*data);
-   *data += 2;
+   *data += 4;
 
DP_VERBOSE(cdev, NETIF_MSG_DRV,
-  "Read config ids: entity id %02x num _attrs = %0d\n",
-  entity_id, count);
+  "Read config ids: num_attrs = %0d\n", count);
/* NVM CFG ID attributes */
for (i = 0; i < count; i++) {
cfg_id = *((u16 *)*data);
*data += 2;
+   entity_id = **data;
+   (*data)++;
len = **data;
(*data)++;
memcpy(buf, *data, len);
@@ -2286,7 +2286,8 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, 
const u8 **data)
QED_NVM_CFG_SET_FLAGS;
 
DP_VERBOSE(cdev, NETIF_MSG_DRV,
-  "cfg_id = %d len = %d\n", cfg_id, len);
+  "cfg_id = %d entity = %d len = %d\n", cfg_id,
+  entity_id, len);
rc = qed_mcp_nvm_set_cfg(hwfn, ptt, cfg_id, entity_id, flags,
 buf, len);
if (rc) {
-- 
1.8.3.1



[PATCH net-next 3/4] qed: Add APIs for configuring grc dump config flags.

2019-08-30 Thread Sudarsana Reddy Kalluru
The patch adds driver support for configuring the grc dump config flags.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_debug.c | 82 +
 drivers/net/ethernet/qlogic/qed/qed_hsi.h   | 15 ++
 drivers/net/ethernet/qlogic/qed/qed_main.c  | 21 
 include/linux/qed/qed_if.h  |  9 
 4 files changed, 127 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c 
b/drivers/net/ethernet/qlogic/qed/qed_debug.c
index 5ea6c4f..859caa6 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_debug.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c
@@ -1756,6 +1756,15 @@ static u32 qed_read_unaligned_dword(u8 *buf)
return dword;
 }
 
+/* Sets the value of the specified GRC param */
+static void qed_grc_set_param(struct qed_hwfn *p_hwfn,
+ enum dbg_grc_params grc_param, u32 val)
+{
+   struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
+
+   dev_data->grc.param_val[grc_param] = val;
+}
+
 /* Returns the value of the specified GRC param */
 static u32 qed_grc_get_param(struct qed_hwfn *p_hwfn,
 enum dbg_grc_params grc_param)
@@ -5119,6 +5128,69 @@ bool qed_read_fw_info(struct qed_hwfn *p_hwfn,
return false;
 }
 
+enum dbg_status qed_dbg_grc_config(struct qed_hwfn *p_hwfn,
+  struct qed_ptt *p_ptt,
+  enum dbg_grc_params grc_param, u32 val)
+{
+   enum dbg_status status;
+   int i;
+
+   DP_VERBOSE(p_hwfn, QED_MSG_DEBUG,
+  "dbg_grc_config: paramId = %d, val = %d\n", grc_param, val);
+
+   status = qed_dbg_dev_init(p_hwfn, p_ptt);
+   if (status != DBG_STATUS_OK)
+   return status;
+
+   /* Initializes the GRC parameters (if not initialized). Needed in order
+* to set the default parameter values for the first time.
+*/
+   qed_dbg_grc_init_params(p_hwfn);
+
+   if (grc_param >= MAX_DBG_GRC_PARAMS)
+   return DBG_STATUS_INVALID_ARGS;
+   if (val < s_grc_param_defs[grc_param].min ||
+   val > s_grc_param_defs[grc_param].max)
+   return DBG_STATUS_INVALID_ARGS;
+
+   if (s_grc_param_defs[grc_param].is_preset) {
+   /* Preset param */
+
+   /* Disabling a preset is not allowed. Call
+* dbg_grc_set_params_default instead.
+*/
+   if (!val)
+   return DBG_STATUS_INVALID_ARGS;
+
+   /* Update all params with the preset values */
+   for (i = 0; i < MAX_DBG_GRC_PARAMS; i++) {
+   u32 preset_val;
+
+   /* Skip persistent params */
+   if (s_grc_param_defs[i].is_persistent)
+   continue;
+
+   /* Find preset value */
+   if (grc_param == DBG_GRC_PARAM_EXCLUDE_ALL)
+   preset_val =
+   s_grc_param_defs[i].exclude_all_preset_val;
+   else if (grc_param == DBG_GRC_PARAM_CRASH)
+   preset_val =
+   s_grc_param_defs[i].crash_preset_val;
+   else
+   return DBG_STATUS_INVALID_ARGS;
+
+   qed_grc_set_param(p_hwfn,
+ (enum dbg_grc_params)i, preset_val);
+   }
+   } else {
+   /* Regular param - set its value */
+   qed_grc_set_param(p_hwfn, grc_param, val);
+   }
+
+   return DBG_STATUS_OK;
+}
+
 /* Assign default GRC param values */
 void qed_dbg_grc_set_params_default(struct qed_hwfn *p_hwfn)
 {
@@ -7997,9 +8069,16 @@ static u32 qed_calc_regdump_header(enum 
debug_print_features feature,
 int qed_dbg_all_data(struct qed_dev *cdev, void *buffer)
 {
u8 cur_engine, omit_engine = 0, org_engine;
+   struct qed_hwfn *p_hwfn =
+   &cdev->hwfns[cdev->dbg_params.engine_for_debug];
+   struct dbg_tools_data *dev_data = &p_hwfn->dbg_info;
+   int grc_params[MAX_DBG_GRC_PARAMS], i;
u32 offset = 0, feature_size;
int rc;
 
+   for (i = 0; i < MAX_DBG_GRC_PARAMS; i++)
+   grc_params[i] = dev_data->grc.param_val[i];
+
if (cdev->num_hwfns == 1)
omit_engine = 1;
 
@@ -8087,6 +8166,9 @@ int qed_dbg_all_data(struct qed_dev *cdev, void *buffer)
   rc);
}
 
+   for (i = 0; i < MAX_DBG_GRC_PARAMS; i++)
+   dev_data->grc.param_val[i] = grc_params[i];
+
/* GRC dump - must be last because when mcp stuck it will
 * clutter idle_chk, reg_fifo, ...
 */
diff --git a/drivers/net/ethernet/q

[PATCH net-next 4/4] qede: Add support for dumping the grc data.

2019-08-30 Thread Sudarsana Reddy Kalluru
This patch adds driver support for configuring grc dump config flags, and
dumping the grc data via ethtool get/set-dump interfaces.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qede/qede.h |  1 +
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 29 +++--
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede.h 
b/drivers/net/ethernet/qlogic/qede/qede.h
index 8f2adde..c303a92 100644
--- a/drivers/net/ethernet/qlogic/qede/qede.h
+++ b/drivers/net/ethernet/qlogic/qede/qede.h
@@ -181,6 +181,7 @@ enum qede_flags_bit {
 enum qede_dump_cmd {
QEDE_DUMP_CMD_NONE = 0,
QEDE_DUMP_CMD_NVM_CFG,
+   QEDE_DUMP_CMD_GRCDUMP,
QEDE_DUMP_CMD_MAX
 };
 
diff --git a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c 
b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
index 2359293..ec27a43 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
@@ -2001,6 +2001,10 @@ static int qede_set_dump(struct net_device *dev, struct 
ethtool_dump *val)
edev->dump_info.args[edev->dump_info.num_args] = val->flag;
edev->dump_info.num_args++;
break;
+   case QEDE_DUMP_CMD_GRCDUMP:
+   rc = edev->ops->common->set_grc_config(edev->cdev,
+  val->flag, 1);
+   break;
default:
break;
}
@@ -2013,14 +2017,24 @@ static int qede_get_dump_flag(struct net_device *dev,
 {
struct qede_dev *edev = netdev_priv(dev);
 
+   if (!edev->ops || !edev->ops->common) {
+   DP_ERR(edev, "Edev ops not populated\n");
+   return -EINVAL;
+   }
+
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:
+   case QEDE_DUMP_CMD_GRCDUMP:
+   dump->flag = QEDE_DUMP_CMD_GRCDUMP;
+   dump->len = edev->ops->common->dbg_all_data_size(edev->cdev);
break;
+   default:
+   DP_ERR(edev, "Invalid cmd = %d\n", edev->dump_info.cmd);
+   return -EINVAL;
}
 
DP_VERBOSE(edev, QED_MSG_DEBUG,
@@ -2033,7 +2047,14 @@ 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;
+   int rc = 0;
+
+   if (!edev->ops || !edev->ops->common) {
+   DP_ERR(edev, "Edev ops not populated\n");
+   edev->dump_info.cmd = QEDE_DUMP_CMD_NONE;
+   edev->dump_info.num_args = 0;
+   return -EINVAL;
+   }
 
switch (edev->dump_info.cmd) {
case QEDE_DUMP_CMD_NVM_CFG:
@@ -2047,6 +2068,10 @@ static int qede_get_dump_data(struct net_device *dev,
  edev->dump_info.args[0],
  edev->dump_info.args[1]);
break;
+   case QEDE_DUMP_CMD_GRCDUMP:
+   memset(buf, 0, dump->len);
+   rc = edev->ops->common->dbg_all_data(edev->cdev, buf);
+   break;
default:
DP_ERR(edev, "Invalid cmd = %d\n", edev->dump_info.cmd);
rc = -EINVAL;
-- 
1.8.3.1



[PATCH net-next 0/4] qed*: Enhancements.

2019-08-30 Thread Sudarsana Reddy Kalluru
The patch series adds couple of enhancements to qed/qede drivers.
  - Support for dumping the config id attributes via ethtool -w/W.
  - Support for dumping the GRC data of required memory regions using
ethtool -w/W interfaces.

Patch (1) adds driver APIs for reading the config id attributes.
Patch (2) adds ethtool support for dumping the config id attributes.
Patch (3) adds support for configuring the GRC dump config flags.
Patch (4) adds ethtool support for dumping the grc dump.

Please consider applying it to net-next.

Sudarsana Reddy Kalluru (4):
  qed: Add APIs for reading config id attributes.
  qede: Add support for reading the config id attributes.
  qed: Add APIs for configuring grc dump config flags.
  qede: Add support for dumping the grc data.

 drivers/net/ethernet/qlogic/qed/qed_debug.c |  82 +
 drivers/net/ethernet/qlogic/qed/qed_hsi.h   |  15 
 drivers/net/ethernet/qlogic/qed/qed_main.c  |  48 ++
 drivers/net/ethernet/qlogic/qed/qed_mcp.c   |  29 ++
 drivers/net/ethernet/qlogic/qed/qed_mcp.h   |  15 
 drivers/net/ethernet/qlogic/qede/qede.h |  15 
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 114 
 include/linux/qed/qed_if.h  |  20 +
 8 files changed, 338 insertions(+)

-- 
1.8.3.1



[PATCH net-next 1/4] qed: Add APIs for reading config id attributes.

2019-08-30 Thread Sudarsana Reddy Kalluru
The patch adds driver support for reading the config id attributes from NVM
flash partition.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_main.c | 27 +++
 drivers/net/ethernet/qlogic/qed/qed_mcp.c  | 29 +
 drivers/net/ethernet/qlogic/qed/qed_mcp.h  | 15 +++
 include/linux/qed/qed_if.h | 11 +++
 4 files changed, 82 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 7891f8c..c9a7571 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -69,6 +69,8 @@
 #define QED_RDMA_SRQS   QED_ROCE_QPS
 #define QED_NVM_CFG_SET_FLAGS  0xE
 #define QED_NVM_CFG_SET_PF_FLAGS   0x1E
+#define QED_NVM_CFG_GET_FLAGS  0xA
+#define QED_NVM_CFG_GET_PF_FLAGS   0x1A
 
 static char version[] =
"QLogic FastLinQ 4 Core Module qed " DRV_MODULE_VERSION "\n";
@@ -2298,6 +2300,30 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, 
const u8 **data)
return rc;
 }
 
+static int qed_nvm_flash_cfg_read(struct qed_dev *cdev, u8 **data,
+ u32 cmd, u32 entity_id)
+{
+   struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
+   struct qed_ptt *ptt;
+   u32 flags, len;
+   int rc = 0;
+
+   ptt = qed_ptt_acquire(hwfn);
+   if (!ptt)
+   return -EAGAIN;
+
+   DP_VERBOSE(cdev, NETIF_MSG_DRV,
+  "Read config cmd = %d entity id %d\n", cmd, entity_id);
+   flags = entity_id ? QED_NVM_CFG_GET_PF_FLAGS : QED_NVM_CFG_GET_FLAGS;
+   rc = qed_mcp_nvm_get_cfg(hwfn, ptt, cmd, entity_id, flags, *data, &len);
+   if (rc)
+   DP_ERR(cdev, "Error %d reading %d\n", rc, cmd);
+
+   qed_ptt_release(hwfn, ptt);
+
+   return rc;
+}
+
 static int qed_nvm_flash(struct qed_dev *cdev, const char *name)
 {
const struct firmware *image;
@@ -2610,6 +2636,7 @@ static u8 qed_get_affin_hwfn_idx(struct qed_dev *cdev)
.db_recovery_del = &qed_db_recovery_del,
.read_module_eeprom = &qed_read_module_eeprom,
.get_affin_hwfn_idx = &qed_get_affin_hwfn_idx,
+   .read_nvm_cfg = &qed_nvm_flash_cfg_read,
 };
 
 void qed_get_protocol_stats(struct qed_dev *cdev,
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index 89462c4..36ddb89 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -3751,6 +3751,35 @@ int qed_mcp_get_ppfid_bitmap(struct qed_hwfn *p_hwfn, 
struct qed_ptt *p_ptt)
return 0;
 }
 
+int qed_mcp_nvm_get_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
+   u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
+   u32 *p_len)
+{
+   u32 mb_param = 0, resp, param;
+   int rc;
+
+   QED_MFW_SET_FIELD(mb_param, DRV_MB_PARAM_NVM_CFG_OPTION_ID, option_id);
+   if (flags & QED_NVM_CFG_OPTION_INIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_INIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_FREE)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_FREE, 1);
+   if (flags & QED_NVM_CFG_OPTION_ENTITY_SEL) {
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL, 1);
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID,
+ entity_id);
+   }
+
+   rc = qed_mcp_nvm_rd_cmd(p_hwfn, p_ptt,
+   DRV_MSG_CODE_GET_NVM_CFG_OPTION,
+   mb_param, &resp, ¶m, p_len, (u32 *)p_buf);
+
+   return rc;
+}
+
 int qed_mcp_nvm_set_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
u32 len)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.h 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
index 83649a8..9c4c276 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
@@ -1209,6 +1209,21 @@ void qed_mcp_resc_lock_default_init(struct 
qed_resc_lock_params *p_lock,
 int qed_mcp_get_ppfid_bitmap(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
 
 /**
+ * @brief Get NVM config attribute value.
+ *
+ * @param p_hwfn
+ * @param p_ptt
+ * @param option_id
+ * @param entity_id
+ * @param flags
+ * @param p_buf
+ * @param p_len
+ */
+int qed_mcp_nvm_get_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
+   u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
+   u32 *p_len);

[PATCH net-next 2/4] qede: Add support for reading the config id attributes.

2019-08-30 Thread Sudarsana Reddy Kalluru
Add driver support for dumping the config id attributes via ethtool dump
interfaces.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qede/qede.h | 14 
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 89 +
 2 files changed, 103 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qede/qede.h 
b/drivers/net/ethernet/qlogic/qede/qede.h
index 0e931c0..8f2adde 100644
--- a/drivers/net/ethernet/qlogic/qede/qede.h
+++ b/drivers/net/ethernet/qlogic/qede/qede.h
@@ -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_devrdma_info;
 
struct bpf_prog *xdp_prog;
+   struct qede_dump_info   dump_info;
 };
 
 enum QEDE_STATE {
diff --git a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c 
b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
index abcee47..2359293 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
@@ -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_COUNT2
 
 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 @@

RE: [PATCH v1] ocfs2/dlm: Move BITS_TO_BYTES() to bitops.h for wider use

2019-08-22 Thread Sudarsana Reddy Kalluru


> -Original Message-
> From: Andy Shevchenko 
> Sent: Thursday, August 22, 2019 2:39 PM
> To: Sudarsana Reddy Kalluru 
> Cc: Joseph Qi ; Mark Fasheh
> ; Joel Becker ; ocfs2-
> de...@oss.oracle.com; Ariel Elior ; GR-everest-linux-l2
> ; David S. Miller
> ; netdev@vger.kernel.org; Colin Ian King
> 
> Subject: Re: [PATCH v1] ocfs2/dlm: Move BITS_TO_BYTES() to bitops.h for
> wider use
> 
> On Thu, Aug 22, 2019 at 05:46:07AM +, Sudarsana Reddy Kalluru wrote:
> >
> > > -Original Message-
> > > From: netdev-ow...@vger.kernel.org 
> On
> > > Behalf Of Andy Shevchenko
> > > Sent: Wednesday, August 21, 2019 2:56 PM
> > > To: Joseph Qi 
> > > Cc: Mark Fasheh ; Joel Becker ;
> > > ocfs2-de...@oss.oracle.com; Ariel Elior ;
> > > Sudarsana Reddy Kalluru ; GR-everest-linux-l2
> > > ; David S. Miller
> > > ; netdev@vger.kernel.org; Colin Ian King
> > > 
> > > Subject: Re: [PATCH v1] ocfs2/dlm: Move BITS_TO_BYTES() to bitops.h
> > > for wider use
> > >
> > > On Wed, Aug 21, 2019 at 09:29:04AM +0800, Joseph Qi wrote:
> > > > On 19/8/21 00:31, Andy Shevchenko wrote:
> > > > > There are users already and will be more of BITS_TO_BYTES() macro.
> > > > > Move it to bitops.h for wider use.
> 
> > > > > -#define BITS_TO_BYTES(x) ((x)/8)>
> > > > I don't think this is a equivalent replace, or it is in fact wrong
> > > > before?
> > >
> > > I was thinking about this one and there are two applications:
> > > - calculus of the amount of structures of certain type per PAGE
> > >   (obviously off-by-one error in the original code IIUC purpose of
> > > STRUCT_SIZE)
> > > - calculus of some threshold based on line speed in bytes per second
> > >   (I dunno it will have any difference on the Gbs / 100 MBs speeds)
> > >
> > I see that both the implementations (existing vs new) yield same value for
> standard speeds 10G (i.e.,1), 1G (1000) that device supports. Hence the
> change look to be ok.
> 
> Thank you for testing, may I use your Tested-by tag?
Sorry, I didn't test the actual driver flows. Was only referring to the output 
values for 1000/1 speed values.

> 
> --
> With Best Regards,
> Andy Shevchenko
> 



RE: [PATCH v1] ocfs2/dlm: Move BITS_TO_BYTES() to bitops.h for wider use

2019-08-21 Thread Sudarsana Reddy Kalluru


> -Original Message-
> From: netdev-ow...@vger.kernel.org  On
> Behalf Of Andy Shevchenko
> Sent: Wednesday, August 21, 2019 2:56 PM
> To: Joseph Qi 
> Cc: Mark Fasheh ; Joel Becker ;
> ocfs2-de...@oss.oracle.com; Ariel Elior ; Sudarsana
> Reddy Kalluru ; GR-everest-linux-l2  linux...@marvell.com>; David S. Miller ;
> netdev@vger.kernel.org; Colin Ian King 
> Subject: Re: [PATCH v1] ocfs2/dlm: Move BITS_TO_BYTES() to bitops.h for
> wider use
> 
> On Wed, Aug 21, 2019 at 09:29:04AM +0800, Joseph Qi wrote:
> > On 19/8/21 00:31, Andy Shevchenko wrote:
> > > There are users already and will be more of BITS_TO_BYTES() macro.
> > > Move it to bitops.h for wider use.
> > >
> > > Signed-off-by: Andy Shevchenko 
> > > ---
> > >  drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h | 1 -
> > >  fs/ocfs2/dlm/dlmcommon.h | 4 
> > >  include/linux/bitops.h   | 1 +
> > >  3 files changed, 1 insertion(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h
> > > b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h
> > > index 066765fbef06..0a59a09ef82f 100644
> > > --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h
> > > +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h
> > > @@ -296,7 +296,6 @@ static inline void bnx2x_dcb_config_qm(struct
> bnx2x *bp, enum cos_mode mode,
> > >   *possible, the driver should only write the valid vnics into the 
> > > internal
> > >   *ram according to the appropriate port mode.
> > >   */
> > > -#define BITS_TO_BYTES(x) ((x)/8)>
> > I don't think this is a equivalent replace, or it is in fact wrong
> > before?
> 
> I was thinking about this one and there are two applications:
> - calculus of the amount of structures of certain type per PAGE
>   (obviously off-by-one error in the original code IIUC purpose of
> STRUCT_SIZE)
> - calculus of some threshold based on line speed in bytes per second
>   (I dunno it will have any difference on the Gbs / 100 MBs speeds)
> 
I see that both the implementations (existing vs new) yield same value for 
standard speeds 10G (i.e.,1), 1G (1000) that device supports. Hence the 
change look to be ok.

> > >  /* CMNG constants, as derived from system spec calculations */
> > >
> > > diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h
> > > index aaf24548b02a..0463dce65bb2 100644
> > > --- a/fs/ocfs2/dlm/dlmcommon.h
> > > +++ b/fs/ocfs2/dlm/dlmcommon.h
> > > @@ -688,10 +688,6 @@ struct dlm_begin_reco
> > >   __be32 pad2;
> > >  };
> > >
> > > -
> > > -#define BITS_PER_BYTE 8
> > > -#define BITS_TO_BYTES(bits)
> > > (((bits)+BITS_PER_BYTE-1)/BITS_PER_BYTE)
> > > -
> > For ocfs2 part, it looks good to me.
> > Reviewed-by: Joseph Qi 
> 
> Thanks!
> 
> >
> > >  struct dlm_query_join_request
> > >  {
> > >   u8 node_idx;
> > > diff --git a/include/linux/bitops.h b/include/linux/bitops.h index
> > > cf074bce3eb3..79d80f5ddf7b 100644
> > > --- a/include/linux/bitops.h
> > > +++ b/include/linux/bitops.h
> > > @@ -5,6 +5,7 @@
> > >  #include 
> > >
> > >  #define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
> > > +#define BITS_TO_BYTES(nr)DIV_ROUND_UP(nr, BITS_PER_BYTE)
> > >  #define BITS_TO_LONGS(nr)DIV_ROUND_UP(nr,
> BITS_PER_TYPE(long))
> > >
> > >  extern unsigned int __sw_hweight8(unsigned int w);
> > >
> 
> --
> With Best Regards,
> Andy Shevchenko
> 



[PATCH net-next v4 1/2] qed: Add API for configuring NVM attributes.

2019-08-14 Thread Sudarsana Reddy Kalluru
The patch adds API for configuring the NVM config attributes using
Management FW (MFW) interfaces.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_hsi.h | 17 
 drivers/net/ethernet/qlogic/qed/qed_mcp.c | 32 +++
 drivers/net/ethernet/qlogic/qed/qed_mcp.h | 20 +++
 3 files changed, 69 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_hsi.h 
b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
index e054f6c..557a12e 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_hsi.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
@@ -12580,6 +12580,8 @@ struct public_drv_mb {
 #define DRV_MSG_CODE_BW_UPDATE_ACK 0x3200
 #define DRV_MSG_CODE_NIG_DRAIN 0x3000
 #define DRV_MSG_CODE_S_TAG_UPDATE_ACK  0x3b00
+#define DRV_MSG_CODE_GET_NVM_CFG_OPTION0x003e
+#define DRV_MSG_CODE_SET_NVM_CFG_OPTION0x003f
 #define DRV_MSG_CODE_INITIATE_PF_FLR0x0201
 #define DRV_MSG_CODE_VF_DISABLED_DONE  0xc000
 #define DRV_MSG_CODE_CFG_VF_MSIX   0xc001
@@ -12748,6 +12750,21 @@ struct public_drv_mb {
 #define DRV_MB_PARAM_FEATURE_SUPPORT_PORT_EEE  0x0002
 #define DRV_MB_PARAM_FEATURE_SUPPORT_FUNC_VLINK0x0001
 
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ID_SHIFT   0
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ID_MASK0x
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ALL_SHIFT  16
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ALL_MASK   0x0001
+#define DRV_MB_PARAM_NVM_CFG_OPTION_INIT_SHIFT 17
+#define DRV_MB_PARAM_NVM_CFG_OPTION_INIT_MASK  0x0002
+#define DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT_SHIFT   18
+#define DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT_MASK0x0004
+#define DRV_MB_PARAM_NVM_CFG_OPTION_FREE_SHIFT 19
+#define DRV_MB_PARAM_NVM_CFG_OPTION_FREE_MASK  0x0008
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL_SHIFT   20
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL_MASK0x0010
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID_SHIFT24
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID_MASK 0x0f00
+
u32 fw_mb_header;
 #define FW_MSG_CODE_MASK   0x
 #define FW_MSG_CODE_UNSUPPORTED 0x
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index 758702c..89462c4 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -3750,3 +3750,35 @@ int qed_mcp_get_ppfid_bitmap(struct qed_hwfn *p_hwfn, 
struct qed_ptt *p_ptt)
 
return 0;
 }
+
+int qed_mcp_nvm_set_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
+   u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
+   u32 len)
+{
+   u32 mb_param = 0, resp, param;
+
+   QED_MFW_SET_FIELD(mb_param, DRV_MB_PARAM_NVM_CFG_OPTION_ID, option_id);
+   if (flags & QED_NVM_CFG_OPTION_ALL)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ALL, 1);
+   if (flags & QED_NVM_CFG_OPTION_INIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_INIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_COMMIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_FREE)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_FREE, 1);
+   if (flags & QED_NVM_CFG_OPTION_ENTITY_SEL) {
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL, 1);
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID,
+ entity_id);
+   }
+
+   return qed_mcp_nvm_wr_cmd(p_hwfn, p_ptt,
+ DRV_MSG_CODE_SET_NVM_CFG_OPTION,
+ mb_param, &resp, ¶m, len, (u32 *)p_buf);
+}
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.h 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
index e4f8fe4..83649a8 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
@@ -251,6 +251,12 @@ struct qed_mfw_tlv_generic {
struct qed_mfw_tlv_iscsi iscsi;
 };
 
+#define QED_NVM_CFG_OPTION_ALL BIT(0)
+#define QED_NVM_CFG_OPTION_INITBIT(1)
+#define QED_NVM_CFG_OPTION_COMMIT   BIT(2)
+#define QED_NVM_CFG_OPTION_FREEBIT(3)
+#define QED_NVM_CFG_OPTION_ENTITY_SEL  BIT(4)
+
 /**
  * @brief - returns the link params of the hw function
  *
@@ -1202,4 +1208,18 @@ void qed_mcp_resc_lock_default_init(struct 
qed_

[PATCH net-next v4 0/2] qed*: Support for NVM config attributes.

2019-08-14 Thread Sudarsana Reddy Kalluru
The patch series adds support for managing the NVM config attributes.
Patch (1) adds functionality to update config attributes via MFW.
Patch (2) adds driver interface for updating the config attributes.

Changes from previous versions:
---
v4: Added more details on the functionality and its usage.
v3: Removed unused variable.
v2: Removed unused API.

Please consider applying this series to "net-next".


Sudarsana Reddy Kalluru (2):
  qed: Add API for configuring NVM attributes.
  qed: Add driver API for flashing the config attributes.

 drivers/net/ethernet/qlogic/qed/qed_hsi.h  | 17 
 drivers/net/ethernet/qlogic/qed/qed_main.c | 68 ++
 drivers/net/ethernet/qlogic/qed/qed_mcp.c  | 32 ++
 drivers/net/ethernet/qlogic/qed/qed_mcp.h  | 20 +
 include/linux/qed/qed_if.h |  1 +
 5 files changed, 138 insertions(+)

-- 
1.8.3.1



[PATCH net-next v4 2/2] qed: Add driver API for flashing the config attributes.

2019-08-14 Thread Sudarsana Reddy Kalluru
The patch adds driver interface for reading the config attributes from user
provided buffer, and updates these values on nvm config flash partition.

This is basically an expansion of our existing ethtool -f implementation.
The management FW has exposed an additional method of configuring some of
the nvram options, and this makes use of that. This implementation will
come into use when newer FW files which contain configuration directives
employing this API will be provided to ethtool -f.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_main.c | 68 ++
 include/linux/qed/qed_if.h |  1 +
 2 files changed, 69 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index e5ac8bd..0a76459 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -67,6 +67,8 @@
 #define QED_ROCE_QPS   (8192)
 #define QED_ROCE_DPIS  (8)
 #define QED_RDMA_SRQS   QED_ROCE_QPS
+#define QED_NVM_CFG_SET_FLAGS  0xE
+#define QED_NVM_CFG_SET_PF_FLAGS   0x1E
 
 static char version[] =
"QLogic FastLinQ 4 Core Module qed " DRV_MODULE_VERSION "\n";
@@ -2231,6 +2233,69 @@ static int qed_nvm_flash_image_validate(struct qed_dev 
*cdev,
return 0;
 }
 
+/* Binary file format -
+ * /--\
+ * 0B  |   0x5 [command index]|
+ * 4B  | Entity ID | Reserved|  Number of config attributes   |
+ * 8B  | Config ID   | Length| Value  |
+ * |  |
+ * \--/
+ * There can be several cfg_id-Length-Value sets as specified by 'Number 
of...'.
+ * Entity ID - A non zero entity value for which the config need to be updated.
+ *
+ * The API parses config attributes from the user provided buffer and flashes
+ * them to the respective NVM path using Management FW inerface.
+ */
+static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data)
+{
+   struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
+   u8 entity_id, len, buf[32];
+   struct qed_ptt *ptt;
+   u16 cfg_id, count;
+   int rc = 0, i;
+   u32 flags;
+
+   ptt = qed_ptt_acquire(hwfn);
+   if (!ptt)
+   return -EAGAIN;
+
+   /* NVM CFG ID attribute header */
+   *data += 4;
+   entity_id = **data;
+   *data += 2;
+   count = *((u16 *)*data);
+   *data += 2;
+
+   DP_VERBOSE(cdev, NETIF_MSG_DRV,
+  "Read config ids: entity id %02x num _attrs = %0d\n",
+  entity_id, count);
+   /* NVM CFG ID attributes */
+   for (i = 0; i < count; i++) {
+   cfg_id = *((u16 *)*data);
+   *data += 2;
+   len = **data;
+   (*data)++;
+   memcpy(buf, *data, len);
+   *data += len;
+
+   flags = entity_id ? QED_NVM_CFG_SET_PF_FLAGS :
+   QED_NVM_CFG_SET_FLAGS;
+
+   DP_VERBOSE(cdev, NETIF_MSG_DRV,
+  "cfg_id = %d len = %d\n", cfg_id, len);
+   rc = qed_mcp_nvm_set_cfg(hwfn, ptt, cfg_id, entity_id, flags,
+buf, len);
+   if (rc) {
+   DP_ERR(cdev, "Error %d configuring %d\n", rc, cfg_id);
+   break;
+   }
+   }
+
+   qed_ptt_release(hwfn, ptt);
+
+   return rc;
+}
+
 static int qed_nvm_flash(struct qed_dev *cdev, const char *name)
 {
const struct firmware *image;
@@ -2272,6 +2337,9 @@ static int qed_nvm_flash(struct qed_dev *cdev, const char 
*name)
rc = qed_nvm_flash_image_access(cdev, &data,
&check_resp);
break;
+   case QED_NVM_FLASH_CMD_NVM_CFG_ID:
+   rc = qed_nvm_flash_cfg_write(cdev, &data);
+   break;
default:
DP_ERR(cdev, "Unknown command %08x\n", cmd_type);
rc = -EINVAL;
diff --git a/include/linux/qed/qed_if.h b/include/linux/qed/qed_if.h
index 2302136..e366399 100644
--- a/include/linux/qed/qed_if.h
+++ b/include/linux/qed/qed_if.h
@@ -804,6 +804,7 @@ enum qed_nvm_flash_cmd {
QED_NVM_FLASH_CMD_FILE_DATA = 0x2,
QED_NVM_FLASH_CMD_FILE_START = 0x3,
QED_NVM_FLASH_CMD_NVM_CHANGE = 0x4,
+   QED_NVM_FLASH_CMD_NVM_CFG_ID = 0x5,
QED_NVM_FLASH_CMD_NVM_MAX,
 };
 
-- 
1.8.3.1



RE: [PATCH net-next v3 2/2] qed: Add driver API for flashing the config attributes.

2019-08-11 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: Ariel Elior 
> Sent: Monday, August 5, 2019 8:00 PM
> To: Sudarsana Reddy Kalluru ; David Miller
> 
> Cc: netdev@vger.kernel.org; Michal Kalderon 
> Subject: RE: [PATCH net-next v3 2/2] qed: Add driver API for flashing the
> config attributes.
> 
> > From: Sudarsana Reddy Kalluru
> > Sent: Tuesday, July 30, 2019 6:36 AM
> > To: David Miller 
> >
> > > -Original Message-
> > > From: David Miller 
> > > Sent: Monday, July 29, 2019 11:34 PM
> > > To: Sudarsana Reddy Kalluru 
> > > Cc: netdev@vger.kernel.org; Michal Kalderon
> ;
> > > Ariel Elior 
> > > Subject: Re: [PATCH net-next v3 2/2] qed: Add driver API for
> > > flashing the config attributes.
> > >
> > > From: Sudarsana Reddy Kalluru 
> > > Date: Sat, 27 Jul 2019 18:55:49 -0700
> > >
> > > > @@ -2268,6 +2330,9 @@ static int qed_nvm_flash(struct qed_dev
> > > > *cdev,
> > > const char *name)
> > > > rc = qed_nvm_flash_image_access(cdev, &data,
> > > > &check_resp);
> > > > break;
> > > > +   case QED_NVM_FLASH_CMD_NVM_CFG_ID:
> > > > +   rc = qed_nvm_flash_cfg_write(cdev, &data);
> > > > +   break;
> >
> > > > default:
> > > > DP_ERR(cdev, "Unknown command %08x\n",
> > > cmd_type);
> > >
> > > I don't see how any existing portable interface can cause this new
> > > code to actually be used.
> > >
> > > You have to explain this to me.
> > The API qed_nvm_flash() is used to flash the user provided data (e.g.,
> > Management FW) to the required partitions of the adapter.
> >- Format of the input file would be - file signature info, followed
> > by one or more data sets.
> >- Each data set is represented with the header followed by its contents.
> > Header captures info such as command name (e.g., FILE_START), data
> > size etc., which specifies how to handle the data.
> > The API qed_nvm_flash() validates the user provided input file, parses
> > the data sets and handles each accordingly. Here one of the data sets
> > (preferably the last one) could be nvm-attributes page (with cmd-id =
> > QED_NVM_FLASH_CMD_NVM_CHANGE).
> 
> This is basically an expansion of our existing ethtool -f implementation.
> The management FW has exposed an additional method of configuring some
> of the nvram options, and this makes use of that. The new code will come
> into use when newer FW files which contain configuration directives
> employing this API will be provided to ethtool -f.
> 
> thanks,
> Ariel

Dave,
The series appears as "changes requested" in patchwork. Please let us know 
if any modifications need to be incorporated on this series?

Thanks,
Sudarsana


RE: [PATCH net-next v3 2/2] qed: Add driver API for flashing the config attributes.

2019-07-29 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: David Miller 
> Sent: Monday, July 29, 2019 11:34 PM
> To: Sudarsana Reddy Kalluru 
> Cc: netdev@vger.kernel.org; Michal Kalderon ;
> Ariel Elior 
> Subject: Re: [PATCH net-next v3 2/2] qed: Add driver API for flashing the
> config attributes.
> 
> From: Sudarsana Reddy Kalluru 
> Date: Sat, 27 Jul 2019 18:55:49 -0700
> 
> > @@ -2268,6 +2330,9 @@ static int qed_nvm_flash(struct qed_dev *cdev,
> const char *name)
> > rc = qed_nvm_flash_image_access(cdev, &data,
> > &check_resp);
> > break;
> > +   case QED_NVM_FLASH_CMD_NVM_CFG_ID:
> > +   rc = qed_nvm_flash_cfg_write(cdev, &data);
> > +   break;

> > default:
> > DP_ERR(cdev, "Unknown command %08x\n",
> cmd_type);
> 
> I don't see how any existing portable interface can cause this new code to
> actually be used.
> 
> You have to explain this to me.
The API qed_nvm_flash() is used to flash the user provided data (e.g., 
Management FW) to the required partitions of the adapter. 
   - Format of the input file would be - file signature info, followed by one 
or more data sets.
   - Each data set is represented with the header followed by its contents. 
Header captures info such as command name (e.g., FILE_START), data size etc., 
which specifies how to handle the data.
The API qed_nvm_flash() validates the user provided input file, parses the data 
sets and handles each accordingly. Here one of the data sets (preferably the 
last one) could be nvm-attributes page (with cmd-id = 
QED_NVM_FLASH_CMD_NVM_CHANGE).  


RE: [PATCH net-next v3 0/2] qed*: Support for NVM config attributes.

2019-07-29 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: David Miller 
> Sent: Sunday, July 28, 2019 7:43 AM
> To: Sudarsana Reddy Kalluru 
> Cc: netdev@vger.kernel.org; Michal Kalderon ;
> Ariel Elior 
> Subject: Re: [PATCH net-next v3 0/2] qed*: Support for NVM config
> attributes.
> 
> From: Sudarsana Reddy Kalluru 
> Date: Sat, 27 Jul 2019 18:55:47 -0700
> 
> > The patch series adds support for managing the NVM config attributes.
> > Patch (1) adds functionality to update config attributes via MFW.
> > Patch (2) adds driver interface for updating the config attributes.
> >
> > Changes from previous versions:
> > ---
> > v3: Removed unused variable.
> > v2: Removed unused API.
> >
> > Please consider applying this series to "net-next".
> 
> I don't see where an existing ethtool method hooks into and calls this new
> NVM code.
Dave, 
  The new API/functionality is invoked as part of ethtool flash (ethtool -f) 
implementation.
Example code path:
   ethtool_ops-->flash_device--> qede_flash_device() --> qed_nvm_flash() --> 
qed_nvm_flash_cfg_write() --> qed_mcp_nvm_set_cfg()
Thanks,
Sudarsana



[PATCH net-next v3 1/2] qed: Add API for configuring NVM attributes.

2019-07-27 Thread Sudarsana Reddy Kalluru
The patch adds API for configuring the NVM config attributes using
Management FW (MFW) interfaces.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_hsi.h | 17 
 drivers/net/ethernet/qlogic/qed/qed_mcp.c | 32 +++
 drivers/net/ethernet/qlogic/qed/qed_mcp.h | 20 +++
 3 files changed, 69 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_hsi.h 
b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
index e054f6c..557a12e 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_hsi.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
@@ -12580,6 +12580,8 @@ struct public_drv_mb {
 #define DRV_MSG_CODE_BW_UPDATE_ACK 0x3200
 #define DRV_MSG_CODE_NIG_DRAIN 0x3000
 #define DRV_MSG_CODE_S_TAG_UPDATE_ACK  0x3b00
+#define DRV_MSG_CODE_GET_NVM_CFG_OPTION0x003e
+#define DRV_MSG_CODE_SET_NVM_CFG_OPTION0x003f
 #define DRV_MSG_CODE_INITIATE_PF_FLR0x0201
 #define DRV_MSG_CODE_VF_DISABLED_DONE  0xc000
 #define DRV_MSG_CODE_CFG_VF_MSIX   0xc001
@@ -12748,6 +12750,21 @@ struct public_drv_mb {
 #define DRV_MB_PARAM_FEATURE_SUPPORT_PORT_EEE  0x0002
 #define DRV_MB_PARAM_FEATURE_SUPPORT_FUNC_VLINK0x0001
 
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ID_SHIFT   0
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ID_MASK0x
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ALL_SHIFT  16
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ALL_MASK   0x0001
+#define DRV_MB_PARAM_NVM_CFG_OPTION_INIT_SHIFT 17
+#define DRV_MB_PARAM_NVM_CFG_OPTION_INIT_MASK  0x0002
+#define DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT_SHIFT   18
+#define DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT_MASK0x0004
+#define DRV_MB_PARAM_NVM_CFG_OPTION_FREE_SHIFT 19
+#define DRV_MB_PARAM_NVM_CFG_OPTION_FREE_MASK  0x0008
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL_SHIFT   20
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL_MASK0x0010
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID_SHIFT24
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID_MASK 0x0f00
+
u32 fw_mb_header;
 #define FW_MSG_CODE_MASK   0x
 #define FW_MSG_CODE_UNSUPPORTED 0x
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index 758702c..89462c4 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -3750,3 +3750,35 @@ int qed_mcp_get_ppfid_bitmap(struct qed_hwfn *p_hwfn, 
struct qed_ptt *p_ptt)
 
return 0;
 }
+
+int qed_mcp_nvm_set_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
+   u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
+   u32 len)
+{
+   u32 mb_param = 0, resp, param;
+
+   QED_MFW_SET_FIELD(mb_param, DRV_MB_PARAM_NVM_CFG_OPTION_ID, option_id);
+   if (flags & QED_NVM_CFG_OPTION_ALL)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ALL, 1);
+   if (flags & QED_NVM_CFG_OPTION_INIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_INIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_COMMIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_FREE)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_FREE, 1);
+   if (flags & QED_NVM_CFG_OPTION_ENTITY_SEL) {
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL, 1);
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID,
+ entity_id);
+   }
+
+   return qed_mcp_nvm_wr_cmd(p_hwfn, p_ptt,
+ DRV_MSG_CODE_SET_NVM_CFG_OPTION,
+ mb_param, &resp, ¶m, len, (u32 *)p_buf);
+}
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.h 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
index e4f8fe4..83649a8 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
@@ -251,6 +251,12 @@ struct qed_mfw_tlv_generic {
struct qed_mfw_tlv_iscsi iscsi;
 };
 
+#define QED_NVM_CFG_OPTION_ALL BIT(0)
+#define QED_NVM_CFG_OPTION_INITBIT(1)
+#define QED_NVM_CFG_OPTION_COMMIT   BIT(2)
+#define QED_NVM_CFG_OPTION_FREEBIT(3)
+#define QED_NVM_CFG_OPTION_ENTITY_SEL  BIT(4)
+
 /**
  * @brief - returns the link params of the hw function
  *
@@ -1202,4 +1208,18 @@ void qed_mcp_resc_lock_default_init(struct 
qed_

[PATCH net-next v3 0/2] qed*: Support for NVM config attributes.

2019-07-27 Thread Sudarsana Reddy Kalluru
The patch series adds support for managing the NVM config attributes.
Patch (1) adds functionality to update config attributes via MFW.
Patch (2) adds driver interface for updating the config attributes.

Changes from previous versions:
---
v3: Removed unused variable.
v2: Removed unused API.

Please consider applying this series to "net-next".

Sudarsana Reddy Kalluru (2):
  qed: Add API for configuring NVM attributes.
  qed: Add driver API for flashing the config attributes.

 drivers/net/ethernet/qlogic/qed/qed_hsi.h  | 17 
 drivers/net/ethernet/qlogic/qed/qed_main.c | 65 ++
 drivers/net/ethernet/qlogic/qed/qed_mcp.c  | 32 +++
 drivers/net/ethernet/qlogic/qed/qed_mcp.h  | 20 +
 include/linux/qed/qed_if.h |  1 +
 5 files changed, 135 insertions(+)

-- 
1.8.3.1



[PATCH net-next v3 2/2] qed: Add driver API for flashing the config attributes.

2019-07-27 Thread Sudarsana Reddy Kalluru
The patch adds driver interface for reading the NVM config request and
update the attributes on nvm config flash partition.
This API can be used by ethtool flash update command (i.e., ethtool -f) to
update config attributes in the NVM flash parition.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_main.c | 65 ++
 include/linux/qed/qed_if.h |  1 +
 2 files changed, 66 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 829dd60..54f00d2 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -67,6 +67,8 @@
 #define QED_ROCE_QPS   (8192)
 #define QED_ROCE_DPIS  (8)
 #define QED_RDMA_SRQS   QED_ROCE_QPS
+#define QED_NVM_CFG_SET_FLAGS  0xE
+#define QED_NVM_CFG_SET_PF_FLAGS   0x1E
 
 static char version[] =
"QLogic FastLinQ 4 Core Module qed " DRV_MODULE_VERSION "\n";
@@ -2227,6 +2229,66 @@ static int qed_nvm_flash_image_validate(struct qed_dev 
*cdev,
return 0;
 }
 
+/* Binary file format -
+ * /--\
+ * 0B  |   0x5 [command index]|
+ * 4B  | Entity ID | Reserved|  Number of config attributes   |
+ * 8B  | Config ID   | Length| Value  |
+ * |  |
+ * \--/
+ * There can be several Cfg_id-Length-Value sets as specified by 'Number 
of...'.
+ * Entity ID - A non zero entity value for which the config need to be updated.
+ */
+static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data)
+{
+   struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
+   u8 entity_id, len, buf[32];
+   struct qed_ptt *ptt;
+   u16 cfg_id, count;
+   int rc = 0, i;
+   u32 flags;
+
+   ptt = qed_ptt_acquire(hwfn);
+   if (!ptt)
+   return -EAGAIN;
+
+   /* NVM CFG ID attribute header */
+   *data += 4;
+   entity_id = **data;
+   *data += 2;
+   count = *((u16 *)*data);
+   *data += 2;
+
+   DP_VERBOSE(cdev, NETIF_MSG_DRV,
+  "Read config ids: entity id %02x num _attrs = %0d\n",
+  entity_id, count);
+   /* NVM CFG ID attributes */
+   for (i = 0; i < count; i++) {
+   cfg_id = *((u16 *)*data);
+   *data += 2;
+   len = **data;
+   (*data)++;
+   memcpy(buf, *data, len);
+   *data += len;
+
+   flags = entity_id ? QED_NVM_CFG_SET_PF_FLAGS :
+   QED_NVM_CFG_SET_FLAGS;
+
+   DP_VERBOSE(cdev, NETIF_MSG_DRV,
+  "cfg_id = %d len = %d\n", cfg_id, len);
+   rc = qed_mcp_nvm_set_cfg(hwfn, ptt, cfg_id, entity_id, flags,
+buf, len);
+   if (rc) {
+   DP_ERR(cdev, "Error %d configuring %d\n", rc, cfg_id);
+   break;
+   }
+   }
+
+   qed_ptt_release(hwfn, ptt);
+
+   return rc;
+}
+
 static int qed_nvm_flash(struct qed_dev *cdev, const char *name)
 {
const struct firmware *image;
@@ -2268,6 +2330,9 @@ static int qed_nvm_flash(struct qed_dev *cdev, const char 
*name)
rc = qed_nvm_flash_image_access(cdev, &data,
&check_resp);
break;
+   case QED_NVM_FLASH_CMD_NVM_CFG_ID:
+   rc = qed_nvm_flash_cfg_write(cdev, &data);
+   break;
default:
DP_ERR(cdev, "Unknown command %08x\n", cmd_type);
rc = -EINVAL;
diff --git a/include/linux/qed/qed_if.h b/include/linux/qed/qed_if.h
index eef02e6..23805ea 100644
--- a/include/linux/qed/qed_if.h
+++ b/include/linux/qed/qed_if.h
@@ -804,6 +804,7 @@ enum qed_nvm_flash_cmd {
QED_NVM_FLASH_CMD_FILE_DATA = 0x2,
QED_NVM_FLASH_CMD_FILE_START = 0x3,
QED_NVM_FLASH_CMD_NVM_CHANGE = 0x4,
+   QED_NVM_FLASH_CMD_NVM_CFG_ID = 0x5,
QED_NVM_FLASH_CMD_NVM_MAX,
 };
 
-- 
1.8.3.1



RE: [PATCH net-next v2 1/2] qed: Add API for configuring NVM attributes.

2019-07-27 Thread Sudarsana Reddy Kalluru


> -Original Message-
> From: netdev-ow...@vger.kernel.org  On
> Behalf Of David Miller
> Sent: Sunday, July 28, 2019 2:30 AM
> To: Sudarsana Reddy Kalluru 
> Cc: netdev@vger.kernel.org; Michal Kalderon ;
> Ariel Elior 
> Subject: Re: [PATCH net-next v2 1/2] qed: Add API for configuring NVM
> attributes.
> 
> From: Sudarsana Reddy Kalluru 
> Date: Fri, 26 Jul 2019 08:52:14 -0700
> 
> > +int qed_mcp_nvm_set_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt
> *p_ptt,
> > +   u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
> > +   u32 len)
> > +{
> > +   u32 mb_param = 0, resp, param;
> > +   int rc;
>  ...
> > +   rc = qed_mcp_nvm_wr_cmd(p_hwfn, p_ptt,
> > +   DRV_MSG_CODE_SET_NVM_CFG_OPTION,
> > +   mb_param, &resp, ¶m, len, (u32
> *)p_buf);
> > +
> > +   return rc;
> 
> 'rc' is completely unnecessary, please just return the function result 
> directly.
> 
> Thank you.

Thanks for your comments. Will send the updated patch.


[PATCH net-next v2 2/2] qed: Add driver API for flashing the config attributes.

2019-07-26 Thread Sudarsana Reddy Kalluru
The patch adds driver interface for reading the NVM config request and
update the attributes on nvm config flash partition.
This API can be used by ethtool flash update command (i.e., ethtool -f) to
update config attributes in the NVM flash parition.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_main.c | 65 ++
 include/linux/qed/qed_if.h |  1 +
 2 files changed, 66 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 829dd60..54f00d2 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -67,6 +67,8 @@
 #define QED_ROCE_QPS   (8192)
 #define QED_ROCE_DPIS  (8)
 #define QED_RDMA_SRQS   QED_ROCE_QPS
+#define QED_NVM_CFG_SET_FLAGS  0xE
+#define QED_NVM_CFG_SET_PF_FLAGS   0x1E
 
 static char version[] =
"QLogic FastLinQ 4 Core Module qed " DRV_MODULE_VERSION "\n";
@@ -2227,6 +2229,66 @@ static int qed_nvm_flash_image_validate(struct qed_dev 
*cdev,
return 0;
 }
 
+/* Binary file format -
+ * /--\
+ * 0B  |   0x5 [command index]|
+ * 4B  | Entity ID | Reserved|  Number of config attributes   |
+ * 8B  | Config ID   | Length| Value  |
+ * |  |
+ * \--/
+ * There can be several Cfg_id-Length-Value sets as specified by 'Number 
of...'.
+ * Entity ID - A non zero entity value for which the config need to be updated.
+ */
+static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data)
+{
+   struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
+   u8 entity_id, len, buf[32];
+   struct qed_ptt *ptt;
+   u16 cfg_id, count;
+   int rc = 0, i;
+   u32 flags;
+
+   ptt = qed_ptt_acquire(hwfn);
+   if (!ptt)
+   return -EAGAIN;
+
+   /* NVM CFG ID attribute header */
+   *data += 4;
+   entity_id = **data;
+   *data += 2;
+   count = *((u16 *)*data);
+   *data += 2;
+
+   DP_VERBOSE(cdev, NETIF_MSG_DRV,
+  "Read config ids: entity id %02x num _attrs = %0d\n",
+  entity_id, count);
+   /* NVM CFG ID attributes */
+   for (i = 0; i < count; i++) {
+   cfg_id = *((u16 *)*data);
+   *data += 2;
+   len = **data;
+   (*data)++;
+   memcpy(buf, *data, len);
+   *data += len;
+
+   flags = entity_id ? QED_NVM_CFG_SET_PF_FLAGS :
+   QED_NVM_CFG_SET_FLAGS;
+
+   DP_VERBOSE(cdev, NETIF_MSG_DRV,
+  "cfg_id = %d len = %d\n", cfg_id, len);
+   rc = qed_mcp_nvm_set_cfg(hwfn, ptt, cfg_id, entity_id, flags,
+buf, len);
+   if (rc) {
+   DP_ERR(cdev, "Error %d configuring %d\n", rc, cfg_id);
+   break;
+   }
+   }
+
+   qed_ptt_release(hwfn, ptt);
+
+   return rc;
+}
+
 static int qed_nvm_flash(struct qed_dev *cdev, const char *name)
 {
const struct firmware *image;
@@ -2268,6 +2330,9 @@ static int qed_nvm_flash(struct qed_dev *cdev, const char 
*name)
rc = qed_nvm_flash_image_access(cdev, &data,
&check_resp);
break;
+   case QED_NVM_FLASH_CMD_NVM_CFG_ID:
+   rc = qed_nvm_flash_cfg_write(cdev, &data);
+   break;
default:
DP_ERR(cdev, "Unknown command %08x\n", cmd_type);
rc = -EINVAL;
diff --git a/include/linux/qed/qed_if.h b/include/linux/qed/qed_if.h
index eef02e6..23805ea 100644
--- a/include/linux/qed/qed_if.h
+++ b/include/linux/qed/qed_if.h
@@ -804,6 +804,7 @@ enum qed_nvm_flash_cmd {
QED_NVM_FLASH_CMD_FILE_DATA = 0x2,
QED_NVM_FLASH_CMD_FILE_START = 0x3,
QED_NVM_FLASH_CMD_NVM_CHANGE = 0x4,
+   QED_NVM_FLASH_CMD_NVM_CFG_ID = 0x5,
QED_NVM_FLASH_CMD_NVM_MAX,
 };
 
-- 
1.8.3.1



[PATCH net-next v2 1/2] qed: Add API for configuring NVM attributes.

2019-07-26 Thread Sudarsana Reddy Kalluru
The patch adds API for configuring the NVM config attributes using
Management FW (MFW) interfaces.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_hsi.h | 17 +++
 drivers/net/ethernet/qlogic/qed/qed_mcp.c | 35 +++
 drivers/net/ethernet/qlogic/qed/qed_mcp.h | 20 ++
 3 files changed, 72 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_hsi.h 
b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
index e054f6c..557a12e 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_hsi.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
@@ -12580,6 +12580,8 @@ struct public_drv_mb {
 #define DRV_MSG_CODE_BW_UPDATE_ACK 0x3200
 #define DRV_MSG_CODE_NIG_DRAIN 0x3000
 #define DRV_MSG_CODE_S_TAG_UPDATE_ACK  0x3b00
+#define DRV_MSG_CODE_GET_NVM_CFG_OPTION0x003e
+#define DRV_MSG_CODE_SET_NVM_CFG_OPTION0x003f
 #define DRV_MSG_CODE_INITIATE_PF_FLR0x0201
 #define DRV_MSG_CODE_VF_DISABLED_DONE  0xc000
 #define DRV_MSG_CODE_CFG_VF_MSIX   0xc001
@@ -12748,6 +12750,21 @@ struct public_drv_mb {
 #define DRV_MB_PARAM_FEATURE_SUPPORT_PORT_EEE  0x0002
 #define DRV_MB_PARAM_FEATURE_SUPPORT_FUNC_VLINK0x0001
 
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ID_SHIFT   0
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ID_MASK0x
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ALL_SHIFT  16
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ALL_MASK   0x0001
+#define DRV_MB_PARAM_NVM_CFG_OPTION_INIT_SHIFT 17
+#define DRV_MB_PARAM_NVM_CFG_OPTION_INIT_MASK  0x0002
+#define DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT_SHIFT   18
+#define DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT_MASK0x0004
+#define DRV_MB_PARAM_NVM_CFG_OPTION_FREE_SHIFT 19
+#define DRV_MB_PARAM_NVM_CFG_OPTION_FREE_MASK  0x0008
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL_SHIFT   20
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL_MASK0x0010
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID_SHIFT24
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID_MASK 0x0f00
+
u32 fw_mb_header;
 #define FW_MSG_CODE_MASK   0x
 #define FW_MSG_CODE_UNSUPPORTED 0x
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index 758702c..daa20cf 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -3750,3 +3750,38 @@ int qed_mcp_get_ppfid_bitmap(struct qed_hwfn *p_hwfn, 
struct qed_ptt *p_ptt)
 
return 0;
 }
+
+int qed_mcp_nvm_set_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
+   u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
+   u32 len)
+{
+   u32 mb_param = 0, resp, param;
+   int rc;
+
+   QED_MFW_SET_FIELD(mb_param, DRV_MB_PARAM_NVM_CFG_OPTION_ID, option_id);
+   if (flags & QED_NVM_CFG_OPTION_ALL)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ALL, 1);
+   if (flags & QED_NVM_CFG_OPTION_INIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_INIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_COMMIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_FREE)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_FREE, 1);
+   if (flags & QED_NVM_CFG_OPTION_ENTITY_SEL) {
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL, 1);
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID,
+ entity_id);
+   }
+
+   rc = qed_mcp_nvm_wr_cmd(p_hwfn, p_ptt,
+   DRV_MSG_CODE_SET_NVM_CFG_OPTION,
+   mb_param, &resp, ¶m, len, (u32 *)p_buf);
+
+   return rc;
+}
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.h 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
index e4f8fe4..83649a8 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.h
@@ -251,6 +251,12 @@ struct qed_mfw_tlv_generic {
struct qed_mfw_tlv_iscsi iscsi;
 };
 
+#define QED_NVM_CFG_OPTION_ALL BIT(0)
+#define QED_NVM_CFG_OPTION_INITBIT(1)
+#define QED_NVM_CFG_OPTION_COMMIT   BIT(2)
+#define QED_NVM_CFG_OPTION_FREEBIT(3)
+#define QED_NVM_CFG_OPTION_ENTITY_SEL  BIT(4)
+
 /**
  * @brief - returns the link params of the hw function
  *
@@ -1202,4 +1208,18 @@ void qed_mcp_resc_

[PATCH net-next v2 0/2] qed*: Support for NVM config attributes.

2019-07-26 Thread Sudarsana Reddy Kalluru
The patch series adds support for managing the NVM config attributes.
Patch (1) adds functionality to update config attributes via MFW.
Patch (2) adds driver interface for updating the config attributes.

Changes from previous versions:
---
v2: Removed unused API.

Please consider applying this series to "net-next".

Sudarsana Reddy Kalluru (2):
  qed: Add API for configuring NVM attributes.
  qed: Add driver API for flashing the config attributes.

 drivers/net/ethernet/qlogic/qed/qed_hsi.h  | 17 
 drivers/net/ethernet/qlogic/qed/qed_main.c | 65 ++
 drivers/net/ethernet/qlogic/qed/qed_mcp.c  | 35 
 drivers/net/ethernet/qlogic/qed/qed_mcp.h  | 20 +
 include/linux/qed/qed_if.h |  1 +
 5 files changed, 138 insertions(+)

-- 
1.8.3.1



RE: [PATCH net-next 2/2] qed: Add API for flashing the nvm attributes.

2019-07-24 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: Saeed Mahameed 
> Sent: Thursday, July 25, 2019 1:13 AM
> To: Sudarsana Reddy Kalluru ;
> da...@davemloft.net
> Cc: Ariel Elior ; Michal Kalderon
> ; netdev@vger.kernel.org
> Subject: [EXT] Re: [PATCH net-next 2/2] qed: Add API for flashing the nvm
> attributes.
> 
> External Email
> 
> --
> On Tue, 2019-07-23 at 21:51 -0700, Sudarsana Reddy Kalluru wrote:
> > The patch adds driver interface for reading the NVM config request and
> > update the attributes on nvm config flash partition.
> >
> 
> You didn't not use the get_cfg API you added in previous patch.
Thanks for your review. Will move this API to the next patch series which will 
plan to send shortly.

> 
> Also can you please clarify how the user reads/write from/to NVM config
> ? i mean what UAPIs and tools are being used ?
NVM config/partition will be updated using ethtool flash update command (i.e., 
ethtool -f) just like the update of 
other flash partitions of qed device. Example code path,
  ethool-flash_device --> qede_flash_device() --> qed_nvm_flash() --> 
qed_nvm_flash_cfg_write()

> 
> > Signed-off-by: Sudarsana Reddy Kalluru 
> > Signed-off-by: Ariel Elior 
> > ---
> >  drivers/net/ethernet/qlogic/qed/qed_main.c | 65
> > ++
> >  include/linux/qed/qed_if.h |  1 +
> >  2 files changed, 66 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c
> > b/drivers/net/ethernet/qlogic/qed/qed_main.c
> > index 829dd60..54f00d2 100644
> > --- a/drivers/net/ethernet/qlogic/qed/qed_main.c
> > +++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
> > @@ -67,6 +67,8 @@
> >  #define QED_ROCE_QPS   (8192)
> >  #define QED_ROCE_DPIS  (8)
> >  #define QED_RDMA_SRQS   QED_ROCE_QPS
> > +#define QED_NVM_CFG_SET_FLAGS  0xE
> > +#define QED_NVM_CFG_SET_PF_FLAGS   0x1E
> >
> >  static char version[] =
> > "QLogic FastLinQ 4 Core Module qed " DRV_MODULE_VERSION
> > "\n";
> > @@ -2227,6 +2229,66 @@ static int qed_nvm_flash_image_validate(struct
> > qed_dev *cdev,
> > return 0;
> >  }
> >
> > +/* Binary file format -
> > + * /--
> > \
> > + * 0B  |   0x5 [command
> > index]|
> > + * 4B  | Entity ID | Reserved|  Number of config
> > attributes   |
> > + * 8B  | Config ID   | Length|
> > Value  |
> > +
> > * |
> > |
> > + * \--
> > /
> > + * There can be several Cfg_id-Length-Value sets as specified by
> > 'Number of...'.
> > + * Entity ID - A non zero entity value for which the config need to
> > be updated.
> > + */
> > +static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8
> > **data)
> > +{
> > +   struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
> > +   u8 entity_id, len, buf[32];
> > +   struct qed_ptt *ptt;
> > +   u16 cfg_id, count;
> > +   int rc = 0, i;
> > +   u32 flags;
> > +
> > +   ptt = qed_ptt_acquire(hwfn);
> > +   if (!ptt)
> > +   return -EAGAIN;
> > +
> > +   /* NVM CFG ID attribute header */
> > +   *data += 4;
> > +   entity_id = **data;
> > +   *data += 2;
> > +   count = *((u16 *)*data);
> > +   *data += 2;
> > +
> > +   DP_VERBOSE(cdev, NETIF_MSG_DRV,
> > +  "Read config ids: entity id %02x num _attrs =
> > %0d\n",
> > +  entity_id, count);
> > +   /* NVM CFG ID attributes */
> > +   for (i = 0; i < count; i++) {
> > +   cfg_id = *((u16 *)*data);
> > +   *data += 2;
> > +   len = **data;
> > +   (*data)++;
> > +   memcpy(buf, *data, len);
> > +   *data += len;
> > +
> > +   flags = entity_id ? QED_NVM_CFG_SET_PF_FLAGS :
> > +   QED_NVM_CFG_SET_FLAGS;
> > +
> > +   DP_VERBOSE(cdev, NETIF_MSG_DRV,
> > +  "cfg_id = %d len = %d\n", cfg_id, len);
> > +   rc = qed_mcp_nvm_set_cfg(hwfn, ptt, cfg_id, entity_id,
> > flags,
> > +buf, len);
> > +   if (rc) {
> > +   DP

[PATCH net-next 1/2] qed: Add APIs for NVM config attributes.

2019-07-23 Thread Sudarsana Reddy Kalluru
The patch adds APIs for reading/configuring the NVM config attributes
using Management FW interfaces.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_hsi.h | 17 
 drivers/net/ethernet/qlogic/qed/qed_mcp.c | 64 +++
 drivers/net/ethernet/qlogic/qed/qed_mcp.h | 14 +++
 3 files changed, 95 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_hsi.h 
b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
index e054f6c..557a12e 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_hsi.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
@@ -12580,6 +12580,8 @@ struct public_drv_mb {
 #define DRV_MSG_CODE_BW_UPDATE_ACK 0x3200
 #define DRV_MSG_CODE_NIG_DRAIN 0x3000
 #define DRV_MSG_CODE_S_TAG_UPDATE_ACK  0x3b00
+#define DRV_MSG_CODE_GET_NVM_CFG_OPTION0x003e
+#define DRV_MSG_CODE_SET_NVM_CFG_OPTION0x003f
 #define DRV_MSG_CODE_INITIATE_PF_FLR0x0201
 #define DRV_MSG_CODE_VF_DISABLED_DONE  0xc000
 #define DRV_MSG_CODE_CFG_VF_MSIX   0xc001
@@ -12748,6 +12750,21 @@ struct public_drv_mb {
 #define DRV_MB_PARAM_FEATURE_SUPPORT_PORT_EEE  0x0002
 #define DRV_MB_PARAM_FEATURE_SUPPORT_FUNC_VLINK0x0001
 
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ID_SHIFT   0
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ID_MASK0x
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ALL_SHIFT  16
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ALL_MASK   0x0001
+#define DRV_MB_PARAM_NVM_CFG_OPTION_INIT_SHIFT 17
+#define DRV_MB_PARAM_NVM_CFG_OPTION_INIT_MASK  0x0002
+#define DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT_SHIFT   18
+#define DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT_MASK0x0004
+#define DRV_MB_PARAM_NVM_CFG_OPTION_FREE_SHIFT 19
+#define DRV_MB_PARAM_NVM_CFG_OPTION_FREE_MASK  0x0008
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL_SHIFT   20
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL_MASK0x0010
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID_SHIFT24
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID_MASK 0x0f00
+
u32 fw_mb_header;
 #define FW_MSG_CODE_MASK   0x
 #define FW_MSG_CODE_UNSUPPORTED 0x
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index 758702c..573911a 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -3750,3 +3750,67 @@ int qed_mcp_get_ppfid_bitmap(struct qed_hwfn *p_hwfn, 
struct qed_ptt *p_ptt)
 
return 0;
 }
+
+int qed_mcp_nvm_get_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
+   u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
+   u32 *p_len)
+{
+   u32 mb_param = 0, resp, param;
+   int rc;
+
+   QED_MFW_SET_FIELD(mb_param, DRV_MB_PARAM_NVM_CFG_OPTION_ID, option_id);
+   if (flags & QED_NVM_CFG_OPTION_INIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_INIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_FREE)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_FREE, 1);
+   if (flags & QED_NVM_CFG_OPTION_ENTITY_SEL) {
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL, 1);
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID,
+ entity_id);
+   }
+
+   rc = qed_mcp_nvm_rd_cmd(p_hwfn, p_ptt,
+   DRV_MSG_CODE_GET_NVM_CFG_OPTION,
+   mb_param, &resp, ¶m, p_len, (u32 *)p_buf);
+
+   return rc;
+}
+
+int qed_mcp_nvm_set_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
+   u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
+   u32 len)
+{
+   u32 mb_param = 0, resp, param;
+   int rc;
+
+   QED_MFW_SET_FIELD(mb_param, DRV_MB_PARAM_NVM_CFG_OPTION_ID, option_id);
+   if (flags & QED_NVM_CFG_OPTION_ALL)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ALL, 1);
+   if (flags & QED_NVM_CFG_OPTION_INIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_INIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_COMMIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_FREE)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_FREE, 1);
+   if (flags

[PATCH net-next 0/2] qed: Support for NVM config attributes.

2019-07-23 Thread Sudarsana Reddy Kalluru
The patch series add support for managing the NVM config attributes.
Patch (1) adds interfaces for read/write config attributes from MFW.
Patch (2) adds driver interface for updating the config attributes.

Sudarsana Reddy Kalluru (2):
  qed: Add APIs for NVM config attributes.
  qed: Add API for flashing the nvm attributes.

 drivers/net/ethernet/qlogic/qed/qed_hsi.h  | 17 
 drivers/net/ethernet/qlogic/qed/qed_main.c | 65 ++
 drivers/net/ethernet/qlogic/qed/qed_mcp.c  | 64 +
 drivers/net/ethernet/qlogic/qed/qed_mcp.h  | 14 +++
 include/linux/qed/qed_if.h |  1 +
 5 files changed, 161 insertions(+)

-- 
1.8.3.1



[PATCH net-next 2/2] qed: Add API for flashing the nvm attributes.

2019-07-23 Thread Sudarsana Reddy Kalluru
The patch adds driver interface for reading the NVM config request and
update the attributes on nvm config flash partition.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_main.c | 65 ++
 include/linux/qed/qed_if.h |  1 +
 2 files changed, 66 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 829dd60..54f00d2 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -67,6 +67,8 @@
 #define QED_ROCE_QPS   (8192)
 #define QED_ROCE_DPIS  (8)
 #define QED_RDMA_SRQS   QED_ROCE_QPS
+#define QED_NVM_CFG_SET_FLAGS  0xE
+#define QED_NVM_CFG_SET_PF_FLAGS   0x1E
 
 static char version[] =
"QLogic FastLinQ 4 Core Module qed " DRV_MODULE_VERSION "\n";
@@ -2227,6 +2229,66 @@ static int qed_nvm_flash_image_validate(struct qed_dev 
*cdev,
return 0;
 }
 
+/* Binary file format -
+ * /--\
+ * 0B  |   0x5 [command index]|
+ * 4B  | Entity ID | Reserved|  Number of config attributes   |
+ * 8B  | Config ID   | Length| Value  |
+ * |  |
+ * \--/
+ * There can be several Cfg_id-Length-Value sets as specified by 'Number 
of...'.
+ * Entity ID - A non zero entity value for which the config need to be updated.
+ */
+static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data)
+{
+   struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
+   u8 entity_id, len, buf[32];
+   struct qed_ptt *ptt;
+   u16 cfg_id, count;
+   int rc = 0, i;
+   u32 flags;
+
+   ptt = qed_ptt_acquire(hwfn);
+   if (!ptt)
+   return -EAGAIN;
+
+   /* NVM CFG ID attribute header */
+   *data += 4;
+   entity_id = **data;
+   *data += 2;
+   count = *((u16 *)*data);
+   *data += 2;
+
+   DP_VERBOSE(cdev, NETIF_MSG_DRV,
+  "Read config ids: entity id %02x num _attrs = %0d\n",
+  entity_id, count);
+   /* NVM CFG ID attributes */
+   for (i = 0; i < count; i++) {
+   cfg_id = *((u16 *)*data);
+   *data += 2;
+   len = **data;
+   (*data)++;
+   memcpy(buf, *data, len);
+   *data += len;
+
+   flags = entity_id ? QED_NVM_CFG_SET_PF_FLAGS :
+   QED_NVM_CFG_SET_FLAGS;
+
+   DP_VERBOSE(cdev, NETIF_MSG_DRV,
+  "cfg_id = %d len = %d\n", cfg_id, len);
+   rc = qed_mcp_nvm_set_cfg(hwfn, ptt, cfg_id, entity_id, flags,
+buf, len);
+   if (rc) {
+   DP_ERR(cdev, "Error %d configuring %d\n", rc, cfg_id);
+   break;
+   }
+   }
+
+   qed_ptt_release(hwfn, ptt);
+
+   return rc;
+}
+
 static int qed_nvm_flash(struct qed_dev *cdev, const char *name)
 {
const struct firmware *image;
@@ -2268,6 +2330,9 @@ static int qed_nvm_flash(struct qed_dev *cdev, const char 
*name)
rc = qed_nvm_flash_image_access(cdev, &data,
&check_resp);
break;
+   case QED_NVM_FLASH_CMD_NVM_CFG_ID:
+   rc = qed_nvm_flash_cfg_write(cdev, &data);
+   break;
default:
DP_ERR(cdev, "Unknown command %08x\n", cmd_type);
rc = -EINVAL;
diff --git a/include/linux/qed/qed_if.h b/include/linux/qed/qed_if.h
index eef02e6..23805ea 100644
--- a/include/linux/qed/qed_if.h
+++ b/include/linux/qed/qed_if.h
@@ -804,6 +804,7 @@ enum qed_nvm_flash_cmd {
QED_NVM_FLASH_CMD_FILE_DATA = 0x2,
QED_NVM_FLASH_CMD_FILE_START = 0x3,
QED_NVM_FLASH_CMD_NVM_CHANGE = 0x4,
+   QED_NVM_FLASH_CMD_NVM_CFG_ID = 0x5,
QED_NVM_FLASH_CMD_NVM_MAX,
 };
 
-- 
1.8.3.1



[PATCH net 1/1] bnx2x: Disable multi-cos feature.

2019-07-23 Thread Sudarsana Reddy Kalluru
Commit 3968d38917eb ("bnx2x: Fix Multi-Cos.") which enabled multi-cos
feature after prolonged time in driver added some regression causing
numerous issues (sudden reboots, tx timeout etc.) reported by customers.
We plan to backout this commit and submit proper fix once we have root
cause of issues reported with this feature enabled.

Fixes: 3968d38917eb ("bnx2x: Fix Multi-Cos.")
Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Manish Chopra 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index e2be5a6..e47ea92 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -1934,8 +1934,7 @@ u16 bnx2x_select_queue(struct net_device *dev, struct 
sk_buff *skb,
}
 
/* select a non-FCoE queue */
-   return netdev_pick_tx(dev, skb, NULL) %
-  (BNX2X_NUM_ETH_QUEUES(bp) * bp->max_cos);
+   return netdev_pick_tx(dev, skb, NULL) % (BNX2X_NUM_ETH_QUEUES(bp));
 }
 
 void bnx2x_set_num_queues(struct bnx2x *bp)
-- 
1.8.3.1



RE: [EXT] Re: [PATCH net-next v2 4/4] qed*: Add devlink support for configuration attributes.

2019-07-08 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: Jakub Kicinski 
> Sent: Tuesday, July 9, 2019 3:17 AM
> To: Sudarsana Reddy Kalluru 
> Cc: da...@davemloft.net; netdev@vger.kernel.org; Michal Kalderon
> ; Ariel Elior ; Jiri Pirko
> 
> Subject: Re: [EXT] Re: [PATCH net-next v2 4/4] qed*: Add devlink support for
> configuration attributes.
> 
> On Mon, 8 Jul 2019 02:31:15 +, Sudarsana Reddy Kalluru wrote:
> > > > > > +   Type: u8
> > > > > > +   Configuration mode: Permanent
> > > > > > +
> > > > > > +dcbx_mode  [PORT, DRIVER-SPECIFIC]
> > > > > > +   Configure DCBX mode for the device.
> > > > > > +   Supported dcbx modes are,
> > > > > > +   Disabled(0), IEEE(1), CEE(2) and
> > > > > > Dynamic(3)
> > > > > > +   Type: u8
> > > > > > +   Configuration mode: Permanent
> > > > >
> > > > > Why is this a permanent parameter?
> > > > >
> > > > This specifies the dcbx_mode to be configured in non-volatile memory.
> > > > The value is persistent and is used in the next load of OS or the mfw.
> > >
> > > And it can't be changed at runtime?
> >
> > Run time dcbx params are not affected via this interface, it only
> > updates config on permanent storage of the port.
> 
> IOW it affects the defaults after boot?  It'd be preferable to have the DCB
> uAPI handle "persistent"/default settings if that's the case.
Yes, it's effective after the reboot. Thanks for your suggestion.


RE: [EXT] Re: [PATCH net-next v2 4/4] qed*: Add devlink support for configuration attributes.

2019-07-07 Thread Sudarsana Reddy Kalluru



> -Original Message-
> From: Jakub Kicinski 
> Sent: Saturday, July 6, 2019 1:09 AM
> To: Sudarsana Reddy Kalluru 
> Cc: da...@davemloft.net; netdev@vger.kernel.org; Michal Kalderon
> ; Ariel Elior ; Jiri Pirko
> 
> Subject: Re: [EXT] Re: [PATCH net-next v2 4/4] qed*: Add devlink support for
> configuration attributes.
> 
> On Fri, 5 Jul 2019 08:22:41 +, Sudarsana Reddy Kalluru wrote:
> > > On Thu, 4 Jul 2019 06:20:11 -0700, Sudarsana Reddy Kalluru wrote:
> > > > This patch adds implementation for devlink callbacks for reading
> > > > and configuring the device attributes.
> > > >
> > > > Signed-off-by: Sudarsana Reddy Kalluru 
> > > > Signed-off-by: Ariel Elior 
> 
> > > > diff --git a/Documentation/networking/devlink-params-qede.txt
> > > > b/Documentation/networking/devlink-params-qede.txt
> > > > new file mode 100644
> > > > index 000..f78a993
> > > > --- /dev/null
> > > > +++ b/Documentation/networking/devlink-params-qede.txt
> > > > @@ -0,0 +1,72 @@
> > > > +enable_sriov   [DEVICE, GENERIC]
> > > > +   Configuration mode: Permanent
> > > > +
> > > > +iwarp_cmt  [DEVICE, DRIVER-SPECIFIC]
> > > > +   Enable iWARP support over 100G device (CMT
> mode).
> > > > +   Type: Boolean
> > > > +   Configuration mode: runtime
> > > > +
> > > > +entity_id  [DEVICE, DRIVER-SPECIFIC]
> > > > +   Set the entity ID value to be used for this 
> > > > device
> > > > +   while reading/configuring the devlink 
> > > > attributes.
> > > > +   Type: u8
> > > > +   Configuration mode: runtime
> > >
> > > Can you explain what this is?
> >
> > Hardware/mfw provides the option to modify/read the config of other
> > PFs. A non-zero entity id represents a partition number (or simply a
> > PF-id) for which the config need to be read/updated.
> 
> Having a parameter which changes the interpretation of other parameters
> makes me quite uncomfortable :(  Could it be a better idea, perhaps, to use
> PCI ports?  We have been discussing PCI ports for a while now, and they will
> probably become a reality soon.  You could then hang the per-PF parameters
> off of the PF ports rather than the device instance?
> 
Agree with you, thanks.

> > > > +device_capabilities[DEVICE, DRIVER-SPECIFIC]
> > > > +   Set the entity ID value to be used for this 
> > > > device
> > > > +   while reading/configuring the devlink 
> > > > attributes.
> > > > +   Type: u8
> > > > +   Configuration mode: runtime
> > >
> > > Looks like you copied the previous text here.
> > Will update it, thanks.
> >
> > >
> > > > +mf_mode[DEVICE, DRIVER-SPECIFIC]
> > > > +   Configure Multi Function mode for the device.
> > > > +   Supported MF modes and the assoicated values 
> > > > are,
> > > > +   MF allowed(0), Default(1), SPIO4(2), 
> > > > NPAR1.0(3),
> > > > +   NPAR1.5(4), NPAR2.0(5), BD(6) and UFP(7)
> > >
> > > NPAR should have a proper API in devlink port, what are the other
> modes?
> > >
> > These are the different modes supported by the Marvell NIC. In our
> > case the mf_mode is per adapter basis, e.g., it's not possible to
> > configure one port in NPAR mode and the other in Default mode.
> 
> Jiri, what are your thoughts on the NPAR support?  It is effectively a PCI 
> split.
> If we are going to support mdev split, should we perhaps have a "depth" or
> "type" of split and allow for users to configure it using the same API?
> 
> > > > +   Type: u8
> > > > +   Configuration mode: Permanent
> > > > +
> > > > +dcbx_mode  [PORT, DRIVER-SPECIFIC]
> > > > +   Configure DCBX mode for the device.
> > > > +   Supported dcbx modes are,
> > > > +   Disabled(0), IEEE(1), CEE(2) and
> > > > Dynamic(3)
> > > > +   Type: u8
> > > > +   Configuration mode: Permanent
> > >
> > > Why is this a permanent parameter?
> > >
> > This specifies the dcbx_mode to be configured in non-volatile memory.
> > The value is persistent and is used in the next load of OS or the mfw.
> 
> And it can't be changed at runtime?
Run time dcbx params are not affected via this interface, it only updates 
config on permanent storage of the port.


RE: [EXT] Re: [PATCH net-next v2 4/4] qed*: Add devlink support for configuration attributes.

2019-07-05 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: Jakub Kicinski 
> Sent: Friday, July 5, 2019 3:38 AM
> To: Sudarsana Reddy Kalluru 
> Cc: da...@davemloft.net; netdev@vger.kernel.org; Michal Kalderon
> ; Ariel Elior ; Jiri Pirko
> 
> Subject: [EXT] Re: [PATCH net-next v2 4/4] qed*: Add devlink support for
> configuration attributes.
> 
> External Email
> 
> --
> On Thu, 4 Jul 2019 06:20:11 -0700, Sudarsana Reddy Kalluru wrote:
> > This patch adds implementation for devlink callbacks for reading and
> > configuring the device attributes.
> >
> > Signed-off-by: Sudarsana Reddy Kalluru 
> > Signed-off-by: Ariel Elior 
> > ---
> >  Documentation/networking/devlink-params-qede.txt |  72 
> >  drivers/net/ethernet/qlogic/qed/qed_main.c   |  38 +
> >  drivers/net/ethernet/qlogic/qede/qede.h  |   3 +
> >  drivers/net/ethernet/qlogic/qede/qede_devlink.c  | 202
> > ++-
> drivers/net/ethernet/qlogic/qede/qede_devlink.h  |  23 +++
> >  include/linux/qed/qed_if.h   |  16 ++
> >  6 files changed, 353 insertions(+), 1 deletion(-)  create mode 100644
> > Documentation/networking/devlink-params-qede.txt
> >
> > diff --git a/Documentation/networking/devlink-params-qede.txt
> > b/Documentation/networking/devlink-params-qede.txt
> > new file mode 100644
> > index 000..f78a993
> > --- /dev/null
> > +++ b/Documentation/networking/devlink-params-qede.txt
> > @@ -0,0 +1,72 @@
> > +enable_sriov   [DEVICE, GENERIC]
> > +   Configuration mode: Permanent
> > +
> > +iwarp_cmt  [DEVICE, DRIVER-SPECIFIC]
> > +   Enable iWARP support over 100G device (CMT
> mode).
> > +   Type: Boolean
> > +   Configuration mode: runtime
> > +
> > +entity_id  [DEVICE, DRIVER-SPECIFIC]
> > +   Set the entity ID value to be used for this device
> > +   while reading/configuring the devlink attributes.
> > +   Type: u8
> > +   Configuration mode: runtime
> 
> Can you explain what this is?
Hardware/mfw provides the option to modify/read the config of other PFs. A 
non-zero entity id represents a partition number (or simply a PF-id) for which 
the config need to be read/updated.

> 
> > +device_capabilities[DEVICE, DRIVER-SPECIFIC]
> > +   Set the entity ID value to be used for this device
> > +   while reading/configuring the devlink attributes.
> > +   Type: u8
> > +   Configuration mode: runtime
> 
> Looks like you copied the previous text here.
Will update it, thanks.

> 
> > +mf_mode[DEVICE, DRIVER-SPECIFIC]
> > +   Configure Multi Function mode for the device.
> > +   Supported MF modes and the assoicated values are,
> > +   MF allowed(0), Default(1), SPIO4(2), NPAR1.0(3),
> > +   NPAR1.5(4), NPAR2.0(5), BD(6) and UFP(7)
> 
> NPAR should have a proper API in devlink port, what are the other modes?
> 
These are the different modes supported by the Marvell NIC. In our case the 
mf_mode is per adapter basis, e.g., it's not possible to configure one port in 
NPAR mode and the other in Default mode.

> > +   Type: u8
> > +   Configuration mode: Permanent
> > +
> > +dcbx_mode  [PORT, DRIVER-SPECIFIC]
> > +   Configure DCBX mode for the device.
> > +   Supported dcbx modes are,
> > +   Disabled(0), IEEE(1), CEE(2) and Dynamic(3)
> > +   Type: u8
> > +   Configuration mode: Permanent
> 
> Why is this a permanent parameter?
> 
This specifies the dcbx_mode to be configured in non-volatile memory. The value 
is persistent and is used in the next load of OS or the mfw.

> > +preboot_oprom  [PORT, DRIVER-SPECIFIC]
> > +   Enable Preboot Option ROM.
> > +   Type: Boolean
> > +   Configuration mode: Permanent
> 
> This should definitely not be a driver specific toggle.
> 
> > +preboot_boot_protocol  [PORT, DRIVER-SPECIFIC]
> > +   Configure preboot Boot protocol.
> > +   Possible values are,
> > +   PXE(0), iSCSI Boot(3), FCoE Boot(4) and NONE(7)
> > +   Type: u8
> > +   C

[PATCH net-next v2 4/4] qed*: Add devlink support for configuration attributes.

2019-07-04 Thread Sudarsana Reddy Kalluru
This patch adds implementation for devlink callbacks for reading and
configuring the device attributes.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 Documentation/networking/devlink-params-qede.txt |  72 
 drivers/net/ethernet/qlogic/qed/qed_main.c   |  38 +
 drivers/net/ethernet/qlogic/qede/qede.h  |   3 +
 drivers/net/ethernet/qlogic/qede/qede_devlink.c  | 202 ++-
 drivers/net/ethernet/qlogic/qede/qede_devlink.h  |  23 +++
 include/linux/qed/qed_if.h   |  16 ++
 6 files changed, 353 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/networking/devlink-params-qede.txt

diff --git a/Documentation/networking/devlink-params-qede.txt 
b/Documentation/networking/devlink-params-qede.txt
new file mode 100644
index 000..f78a993
--- /dev/null
+++ b/Documentation/networking/devlink-params-qede.txt
@@ -0,0 +1,72 @@
+enable_sriov   [DEVICE, GENERIC]
+   Configuration mode: Permanent
+
+iwarp_cmt  [DEVICE, DRIVER-SPECIFIC]
+   Enable iWARP support over 100G device (CMT mode).
+   Type: Boolean
+   Configuration mode: runtime
+
+entity_id  [DEVICE, DRIVER-SPECIFIC]
+   Set the entity ID value to be used for this device
+   while reading/configuring the devlink attributes.
+   Type: u8
+   Configuration mode: runtime
+
+device_capabilities[DEVICE, DRIVER-SPECIFIC]
+   Set the entity ID value to be used for this device
+   while reading/configuring the devlink attributes.
+   Type: u8
+   Configuration mode: runtime
+
+mf_mode[DEVICE, DRIVER-SPECIFIC]
+   Configure Multi Function mode for the device.
+   Supported MF modes and the assoicated values are,
+   MF allowed(0), Default(1), SPIO4(2), NPAR1.0(3),
+   NPAR1.5(4), NPAR2.0(5), BD(6) and UFP(7)
+   Type: u8
+   Configuration mode: Permanent
+
+dcbx_mode  [PORT, DRIVER-SPECIFIC]
+   Configure DCBX mode for the device.
+   Supported dcbx modes are,
+   Disabled(0), IEEE(1), CEE(2) and Dynamic(3)
+   Type: u8
+   Configuration mode: Permanent
+
+preboot_oprom  [PORT, DRIVER-SPECIFIC]
+   Enable Preboot Option ROM.
+   Type: Boolean
+   Configuration mode: Permanent
+
+preboot_boot_protocol  [PORT, DRIVER-SPECIFIC]
+   Configure preboot Boot protocol.
+   Possible values are,
+   PXE(0), iSCSI Boot(3), FCoE Boot(4) and NONE(7)
+   Type: u8
+   Configuration mode: Permanent
+
+preboot_vlan   [PORT, DRIVER-SPECIFIC]
+   Preboot VLAN.
+   Type: u16
+   Configuration mode: Permanent
+
+preboot_vlan_value [PORT, DRIVER-SPECIFIC]
+   Configure Preboot VLAN value.
+   Type: u16
+   Configuration mode: Permanent
+
+mba_delay_time [PORT, DRIVER-SPECIFIC]
+   Configure MBA Delay Time. Supported range is [0-15].
+   Type: u8
+   Configuration mode: Permanent
+
+mba_setup_hot_key  [PORT, DRIVER-SPECIFIC]
+   Configure MBA setup Hot Key. Possible values are,
+   Ctrl S(0) and Ctrl B(1).
+   Type: u8
+   Configuration mode: Permanent
+
+mba_hide_setup_prompt  [PORT, DRIVER-SPECIFIC]
+   Configure MBA hide setup prompt.
+   Type: Boolean
+   Configuration mode: Permanent
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index f0183e2..3d43140 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -2388,6 +2388,42 @@ static void qed_set_iwarp_cmt(struct qed_dev *cdev, bool 
iwarp_cmt)
cdev->iwarp_cmt = iwarp_cmt;
 }
 
+static int qed_get_cfg_attr(struct qed_dev *cdev, u16 cmd, u8 entity, u32 
flags,
+   u8 *buf, int *len)
+{
+   struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
+   struct qed_ptt *ptt;
+   int status = 0;
+
+   ptt = qed_ptt_acquire(hwfn);
+   if (!ptt)
+   return -EAGAIN;
+
+   status = qed_mcp_nvm_get_cfg(hwfn, ptt, cmd, entity, flags, buf, len);
+
+   qed_ptt_release(hwfn, ptt);
+
+   return status;
+}
+
+static int qed_set_cfg_attr(str

[PATCH net-next v2 2/4] qed: Add APIs for device attributes configuration.

2019-07-04 Thread Sudarsana Reddy Kalluru
The patch adds driver APIs for reading/configuring the device attributes.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_hsi.h | 17 
 drivers/net/ethernet/qlogic/qed/qed_mcp.c | 64 +++
 drivers/net/ethernet/qlogic/qed/qed_mcp.h | 14 +++
 3 files changed, 95 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_hsi.h 
b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
index e054f6c..557a12e 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_hsi.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
@@ -12580,6 +12580,8 @@ struct public_drv_mb {
 #define DRV_MSG_CODE_BW_UPDATE_ACK 0x3200
 #define DRV_MSG_CODE_NIG_DRAIN 0x3000
 #define DRV_MSG_CODE_S_TAG_UPDATE_ACK  0x3b00
+#define DRV_MSG_CODE_GET_NVM_CFG_OPTION0x003e
+#define DRV_MSG_CODE_SET_NVM_CFG_OPTION0x003f
 #define DRV_MSG_CODE_INITIATE_PF_FLR0x0201
 #define DRV_MSG_CODE_VF_DISABLED_DONE  0xc000
 #define DRV_MSG_CODE_CFG_VF_MSIX   0xc001
@@ -12748,6 +12750,21 @@ struct public_drv_mb {
 #define DRV_MB_PARAM_FEATURE_SUPPORT_PORT_EEE  0x0002
 #define DRV_MB_PARAM_FEATURE_SUPPORT_FUNC_VLINK0x0001
 
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ID_SHIFT   0
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ID_MASK0x
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ALL_SHIFT  16
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ALL_MASK   0x0001
+#define DRV_MB_PARAM_NVM_CFG_OPTION_INIT_SHIFT 17
+#define DRV_MB_PARAM_NVM_CFG_OPTION_INIT_MASK  0x0002
+#define DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT_SHIFT   18
+#define DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT_MASK0x0004
+#define DRV_MB_PARAM_NVM_CFG_OPTION_FREE_SHIFT 19
+#define DRV_MB_PARAM_NVM_CFG_OPTION_FREE_MASK  0x0008
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL_SHIFT   20
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL_MASK0x0010
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID_SHIFT24
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID_MASK 0x0f00
+
u32 fw_mb_header;
 #define FW_MSG_CODE_MASK   0x
 #define FW_MSG_CODE_UNSUPPORTED 0x
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index 758702c..573911a 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -3750,3 +3750,67 @@ int qed_mcp_get_ppfid_bitmap(struct qed_hwfn *p_hwfn, 
struct qed_ptt *p_ptt)
 
return 0;
 }
+
+int qed_mcp_nvm_get_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
+   u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
+   u32 *p_len)
+{
+   u32 mb_param = 0, resp, param;
+   int rc;
+
+   QED_MFW_SET_FIELD(mb_param, DRV_MB_PARAM_NVM_CFG_OPTION_ID, option_id);
+   if (flags & QED_NVM_CFG_OPTION_INIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_INIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_FREE)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_FREE, 1);
+   if (flags & QED_NVM_CFG_OPTION_ENTITY_SEL) {
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL, 1);
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID,
+ entity_id);
+   }
+
+   rc = qed_mcp_nvm_rd_cmd(p_hwfn, p_ptt,
+   DRV_MSG_CODE_GET_NVM_CFG_OPTION,
+   mb_param, &resp, ¶m, p_len, (u32 *)p_buf);
+
+   return rc;
+}
+
+int qed_mcp_nvm_set_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
+   u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
+   u32 len)
+{
+   u32 mb_param = 0, resp, param;
+   int rc;
+
+   QED_MFW_SET_FIELD(mb_param, DRV_MB_PARAM_NVM_CFG_OPTION_ID, option_id);
+   if (flags & QED_NVM_CFG_OPTION_ALL)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ALL, 1);
+   if (flags & QED_NVM_CFG_OPTION_INIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_INIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_COMMIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_FREE)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_FREE, 1);
+   if (flags & QED_NVM_CFG_OPTION_ENTITY_SEL) {
+ 

[PATCH net-next v2 1/4] devlink: Add APIs to publish/unpublish the port parameters.

2019-07-04 Thread Sudarsana Reddy Kalluru
Kernel has no interface to publish the devlink port parameters. This is
required for exporting the port params to the user space, so that user
can read or update the port params.
This patch adds devlink interfaces (for drivers) to publish/unpublish the
devlink port parameters.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 include/net/devlink.h |  2 ++
 net/core/devlink.c| 42 ++
 2 files changed, 44 insertions(+)

diff --git a/include/net/devlink.h b/include/net/devlink.h
index 6625ea0..47a1e8f 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -653,6 +653,8 @@ int devlink_port_params_register(struct devlink_port 
*devlink_port,
 void devlink_port_params_unregister(struct devlink_port *devlink_port,
const struct devlink_param *params,
size_t params_count);
+void devlink_port_params_publish(struct devlink_port *devlink_port);
+void devlink_port_params_unpublish(struct devlink_port *ddevlink_port);
 int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
   union devlink_param_value *init_val);
 int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 89c5337..0cd7994 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -6380,6 +6380,48 @@ void devlink_port_params_unregister(struct devlink_port 
*devlink_port,
 }
 EXPORT_SYMBOL_GPL(devlink_port_params_unregister);
 
+/**
+ * devlink_port_params_publish - publish port configuration parameters
+ *
+ * @devlink_port: devlink port
+ *
+ * Publish previously registered port configuration parameters.
+ */
+void devlink_port_params_publish(struct devlink_port *devlink_port)
+{
+   struct devlink_param_item *param_item;
+
+   list_for_each_entry(param_item, &devlink_port->param_list, list) {
+   if (param_item->published)
+   continue;
+   param_item->published = true;
+   devlink_param_notify(devlink_port->devlink, devlink_port->index,
+param_item, DEVLINK_CMD_PORT_PARAM_NEW);
+   }
+}
+EXPORT_SYMBOL_GPL(devlink_port_params_publish);
+
+/**
+ * devlink_port_params_unpublish - unpublish port configuration parameters
+ *
+ * @devlink_port: devlink port
+ *
+ * Unpublish previously registered port configuration parameters.
+ */
+void devlink_port_params_unpublish(struct devlink_port *devlink_port)
+{
+   struct devlink_param_item *param_item;
+
+   list_for_each_entry(param_item, &devlink_port->param_list, list) {
+   if (!param_item->published)
+   continue;
+   param_item->published = false;
+   devlink_param_notify(devlink_port->devlink, devlink_port->index,
+param_item, DEVLINK_CMD_PORT_PARAM_DEL);
+   }
+}
+EXPORT_SYMBOL_GPL(devlink_port_params_unpublish);
+
 static int
 __devlink_param_driverinit_value_get(struct list_head *param_list, u32 
param_id,
 union devlink_param_value *init_val)
-- 
1.8.3.1



[PATCH net-next v2 0/4] qed*/devlink: Devlink support for config attributes.

2019-07-04 Thread Sudarsana Reddy Kalluru
The patch series adds support for managing the config attributes using
devlink interfaces.

Patch (1) adds the APIs for publishing the devlink port params. Clubbing
this qed patches as per the review comment (i.e., need at least one
consumer for the new APIs).

Patches (2)-(4) adds the qed/qede devlink support for managing the
device/port attributes.

Please consider applying it to 'net-next' tree.

Sudarsana Reddy Kalluru (4):
  devlink: Add APIs to publish/unpublish the port parameters.
  qed: Add APIs for device attributes configuration.
  qed*: Add new file for devlink implementation.
  qed*: Add devlink support for configuration attributes.

 Documentation/networking/devlink-params-qede.txt |  72 ++
 drivers/net/ethernet/qlogic/qed/qed.h|   1 -
 drivers/net/ethernet/qlogic/qed/qed_hsi.h|  17 ++
 drivers/net/ethernet/qlogic/qed/qed_main.c   | 160 
 drivers/net/ethernet/qlogic/qed/qed_mcp.c|  64 +
 drivers/net/ethernet/qlogic/qed/qed_mcp.h|  14 ++
 drivers/net/ethernet/qlogic/qede/Makefile|   2 +-
 drivers/net/ethernet/qlogic/qede/qede.h  |   5 +
 drivers/net/ethernet/qlogic/qede/qede_devlink.c  | 294 +++
 drivers/net/ethernet/qlogic/qede/qede_devlink.h  |  41 
 drivers/net/ethernet/qlogic/qede/qede_main.c |  13 +
 include/linux/qed/qed_if.h   |  19 ++
 include/net/devlink.h|   2 +
 net/core/devlink.c   |  42 
 14 files changed, 634 insertions(+), 112 deletions(-)
 create mode 100644 Documentation/networking/devlink-params-qede.txt
 create mode 100644 drivers/net/ethernet/qlogic/qede/qede_devlink.c
 create mode 100644 drivers/net/ethernet/qlogic/qede/qede_devlink.h

-- 
1.8.3.1



[PATCH net-next v2 3/4] qed*: Add new file for devlink implementation.

2019-07-04 Thread Sudarsana Reddy Kalluru
Moving devlink implementation from qed to qede driver. The change is
required as qede is the actual PCI driver and qed is only the control
driver.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed.h   |   1 -
 drivers/net/ethernet/qlogic/qed/qed_main.c  | 122 +++-
 drivers/net/ethernet/qlogic/qede/Makefile   |   2 +-
 drivers/net/ethernet/qlogic/qede/qede.h |   2 +
 drivers/net/ethernet/qlogic/qede/qede_devlink.c |  94 ++
 drivers/net/ethernet/qlogic/qede/qede_devlink.h |  18 
 drivers/net/ethernet/qlogic/qede/qede_main.c|  13 +++
 include/linux/qed/qed_if.h  |   3 +
 8 files changed, 143 insertions(+), 112 deletions(-)
 create mode 100644 drivers/net/ethernet/qlogic/qede/qede_devlink.c
 create mode 100644 drivers/net/ethernet/qlogic/qede/qede_devlink.h

diff --git a/drivers/net/ethernet/qlogic/qed/qed.h 
b/drivers/net/ethernet/qlogic/qed/qed.h
index 89fe091..cebd822 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -864,7 +864,6 @@ struct qed_dev {
u32 rdma_max_srq_sge;
u16 tunn_feature_mask;
 
-   struct devlink  *dl;
booliwarp_cmt;
 };
 
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 829dd60..f0183e2 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -48,7 +48,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "qed.h"
 #include "qed_sriov.h"
@@ -343,107 +342,6 @@ static int qed_set_power_state(struct qed_dev *cdev, 
pci_power_t state)
return 0;
 }
 
-struct qed_devlink {
-   struct qed_dev *cdev;
-};
-
-enum qed_devlink_param_id {
-   QED_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
-   QED_DEVLINK_PARAM_ID_IWARP_CMT,
-};
-
-static int qed_dl_param_get(struct devlink *dl, u32 id,
-   struct devlink_param_gset_ctx *ctx)
-{
-   struct qed_devlink *qed_dl;
-   struct qed_dev *cdev;
-
-   qed_dl = devlink_priv(dl);
-   cdev = qed_dl->cdev;
-   ctx->val.vbool = cdev->iwarp_cmt;
-
-   return 0;
-}
-
-static int qed_dl_param_set(struct devlink *dl, u32 id,
-   struct devlink_param_gset_ctx *ctx)
-{
-   struct qed_devlink *qed_dl;
-   struct qed_dev *cdev;
-
-   qed_dl = devlink_priv(dl);
-   cdev = qed_dl->cdev;
-   cdev->iwarp_cmt = ctx->val.vbool;
-
-   return 0;
-}
-
-static const struct devlink_param qed_devlink_params[] = {
-   DEVLINK_PARAM_DRIVER(QED_DEVLINK_PARAM_ID_IWARP_CMT,
-"iwarp_cmt", DEVLINK_PARAM_TYPE_BOOL,
-BIT(DEVLINK_PARAM_CMODE_RUNTIME),
-qed_dl_param_get, qed_dl_param_set, NULL),
-};
-
-static const struct devlink_ops qed_dl_ops;
-
-static int qed_devlink_register(struct qed_dev *cdev)
-{
-   union devlink_param_value value;
-   struct qed_devlink *qed_dl;
-   struct devlink *dl;
-   int rc;
-
-   dl = devlink_alloc(&qed_dl_ops, sizeof(*qed_dl));
-   if (!dl)
-   return -ENOMEM;
-
-   qed_dl = devlink_priv(dl);
-
-   cdev->dl = dl;
-   qed_dl->cdev = cdev;
-
-   rc = devlink_register(dl, &cdev->pdev->dev);
-   if (rc)
-   goto err_free;
-
-   rc = devlink_params_register(dl, qed_devlink_params,
-ARRAY_SIZE(qed_devlink_params));
-   if (rc)
-   goto err_unregister;
-
-   value.vbool = false;
-   devlink_param_driverinit_value_set(dl,
-  QED_DEVLINK_PARAM_ID_IWARP_CMT,
-  value);
-
-   devlink_params_publish(dl);
-   cdev->iwarp_cmt = false;
-
-   return 0;
-
-err_unregister:
-   devlink_unregister(dl);
-
-err_free:
-   cdev->dl = NULL;
-   devlink_free(dl);
-
-   return rc;
-}
-
-static void qed_devlink_unregister(struct qed_dev *cdev)
-{
-   if (!cdev->dl)
-   return;
-
-   devlink_params_unregister(cdev->dl, qed_devlink_params,
- ARRAY_SIZE(qed_devlink_params));
-
-   devlink_unregister(cdev->dl);
-   devlink_free(cdev->dl);
-}
-
 /* probing */
 static struct qed_dev *qed_probe(struct pci_dev *pdev,
 struct qed_probe_params *params)
@@ -472,12 +370,6 @@ static struct qed_dev *qed_probe(struct pci_dev *pdev,
}
DP_INFO(cdev, "PCI init completed successfully\n");
 
-   rc = qed_devlink_register(cdev);
-   if (rc) {
-   DP_INFO(cdev, "Failed to register devlink.\n");
-   goto err2;
-   }
-
rc = 

RE: [EXT] Re: [PATCH net-next 4/4] qed: Add devlink support for configuration attributes.

2019-07-03 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: Jakub Kicinski 
> Sent: Wednesday, July 3, 2019 11:13 PM
> To: Sudarsana Reddy Kalluru 
> Cc: Jiri Pirko ; da...@davemloft.net;
> netdev@vger.kernel.org; Michal Kalderon ; Ariel
> Elior 
> Subject: Re: [EXT] Re: [PATCH net-next 4/4] qed: Add devlink support for
> configuration attributes.
> 
> On Wed, 3 Jul 2019 12:56:39 +, Sudarsana Reddy Kalluru wrote:
> > Apologies for bringing this topic again. From the driver(s) code
> > paths/'devlink man pages', I understood that devlink-port object is an
> > entity on top of the PCI bus device. Some drivers say NFP represents
> > vnics (on pci-dev) as a devlink-ports and, some represents
> > (virtual?) ports on the PF/device as devlink-ports. In the case of
> > Marvell NIC driver, we don't have [port] partitioning of the PCI
> > device. And the config attributes are specific to PCI-device (not the
> > vports/vnics of PF). Hence I didn't see a need for creating
> > devlink-port objects in the system for Marvell NICs. And planning to
> > add the config attributes to 'devlink-dev' object. Please let me know
> > if my understanding and the proposal is ok?
> 
> I understand where you're coming from.
> 
> We want to make that judgement call on attribute-by-attribute basis.
> We want consistency across vendors (and, frankly, multiple drivers of the
> same vendor).  If attribute looks like it belongs to the port, rather than the
> entire device/ASIC operation, we should make it a port attribute.

Thanks for your mail. I'll go with creating PCI-dev/0 (i.e., port-id 0) for 
port based attributes as there's no port partitioning for Marvell NICs.


RE: [EXT] Re: [PATCH net-next 4/4] qed: Add devlink support for configuration attributes.

2019-07-03 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: Jiri Pirko 
> Sent: Thursday, June 20, 2019 7:08 PM
> To: Sudarsana Reddy Kalluru 
> Cc: Jakub Kicinski ; da...@davemloft.net;
> netdev@vger.kernel.org; Michal Kalderon ; Ariel
> Elior 
> Subject: Re: [EXT] Re: [PATCH net-next 4/4] qed: Add devlink support for
> configuration attributes.
> 
> Thu, Jun 20, 2019 at 02:09:29PM CEST, skall...@marvell.com wrote:
> >> -Original Message-
> >> From: Jakub Kicinski 
> >> Sent: Tuesday, June 18, 2019 4:24 AM
> >> To: Sudarsana Reddy Kalluru 
> >> Cc: da...@davemloft.net; netdev@vger.kernel.org; Michal Kalderon
> >> ; Ariel Elior ; Jiri Pirko
> >> 
> >> Subject: [EXT] Re: [PATCH net-next 4/4] qed: Add devlink support for
> >> configuration attributes.
> >>
> >> External Email
> >>
> >> -
> >> - On Mon, 17 Jun 2019 04:45:28 -0700, Sudarsana Reddy Kalluru wrote:
> >> > This patch adds implementation for devlink callbacks for reading/
> >> > configuring the device attributes.
> >> >
> >> > Signed-off-by: Sudarsana Reddy Kalluru 
> >> > Signed-off-by: Ariel Elior 
> >>
> >> You need to provide documentation for your parameters, plus some of
> >> them look like they should potentially be port params, not device params.
> >
> >Thanks a lot for your review. Will add the required documentation. In case
> of Marvell adapter, any of the device/adapter/port parameters can be
> read/configurable via any PF (ethdev) on the port. Hence adding the
> commands at device level. Hope this is fine.
> 
> No it is not. Port param should be port param.
> 
> Also please be careful not to add any generic param as driver specific.
> 
> Thanks!
Apologies for bringing this topic again. From the driver(s) code paths/'devlink 
man pages', I understood that devlink-port object is an entity on top of the 
PCI bus device.
Some drivers say NFP represents vnics (on pci-dev) as a devlink-ports and, some 
represents (virtual?) ports on the PF/device as devlink-ports.
In the case of Marvell NIC driver, we don't have [port] partitioning of the PCI 
device. And the config attributes are specific to PCI-device (not the 
vports/vnics of PF).
Hence I didn't see a need for creating devlink-port objects in the system for 
Marvell NICs. And planning to add the config attributes to 'devlink-dev' object.
Please let me know if my understanding and the proposal is ok?

Code paths which use devlink-port:
   mlx4_load_one(struct pci_dev *pdev):  mlx4_init_port_info(1 .. 
dev->caps.num_ports) -> devlink_port_register()
   nfp_net_pf_init_vnics (1 .. pf->vnics) -> nfp_net_pf_init_vnic() -> 
nfp_devlink_port_register()
   nsim_dev_probe (1 .. nsim_bus_dev->port_count) -> __nsim_dev_port_add() -> 
devlink_port_register ()

man page for 'devlink-port':
   devlink port set - change devlink port attributes
   DEV/PORT_INDEX - specifies the devlink port to operate on.

   devlink port show pci/:01:00.0/1
   Shows the state of specified devlink port.


[PATCH net-next v2 1/1] qed: Add support for Timestamping the unicast PTP packets.

2019-07-02 Thread Sudarsana Reddy Kalluru
This patch adds driver changes to detect/timestamp the unicast PTP packets.

Changes from previous version:
---
v2: Defined a macro for unicast ptp param mask.

Please consider applying this to "net-next".

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_ptp.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_ptp.c 
b/drivers/net/ethernet/qlogic/qed/qed_ptp.c
index f3ebdc5..0dacf2c 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ptp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ptp.c
@@ -44,6 +44,8 @@
 /* Add/subtract the Adjustment_Value when making a Drift adjustment */
 #define QED_DRIFT_CNTR_DIRECTION_SHIFT 31
 #define QED_TIMESTAMP_MASK BIT(16)
+/* Param mask for Hardware to detect/timestamp the unicast PTP packets */
+#define QED_PTP_UCAST_PARAM_MASK   0xF
 
 static enum qed_resc_lock qed_ptcdev_to_resc(struct qed_hwfn *p_hwfn)
 {
@@ -243,7 +245,8 @@ static int qed_ptp_hw_cfg_filters(struct qed_dev *cdev,
return -EINVAL;
}
 
-   qed_wr(p_hwfn, p_ptt, NIG_REG_LLH_PTP_PARAM_MASK, 0);
+   qed_wr(p_hwfn, p_ptt, NIG_REG_LLH_PTP_PARAM_MASK,
+  QED_PTP_UCAST_PARAM_MASK);
qed_wr(p_hwfn, p_ptt, NIG_REG_LLH_PTP_RULE_MASK, rule_mask);
qed_wr(p_hwfn, p_ptt, NIG_REG_RX_PTP_EN, enable_cfg);
 
@@ -253,7 +256,8 @@ static int qed_ptp_hw_cfg_filters(struct qed_dev *cdev,
qed_wr(p_hwfn, p_ptt, NIG_REG_TX_LLH_PTP_RULE_MASK, 0x3FFF);
} else {
qed_wr(p_hwfn, p_ptt, NIG_REG_TX_PTP_EN, enable_cfg);
-   qed_wr(p_hwfn, p_ptt, NIG_REG_TX_LLH_PTP_PARAM_MASK, 0);
+   qed_wr(p_hwfn, p_ptt, NIG_REG_TX_LLH_PTP_PARAM_MASK,
+  QED_PTP_UCAST_PARAM_MASK);
qed_wr(p_hwfn, p_ptt, NIG_REG_TX_LLH_PTP_RULE_MASK, rule_mask);
}
 
-- 
1.8.3.1



RE: [PATCH net-next 1/1] devlink: Add APIs to publish/unpublish the port parameters.

2019-07-02 Thread Sudarsana Reddy Kalluru


> -Original Message-
> From: Parav Pandit 
> Sent: Tuesday, July 2, 2019 10:49 PM
> To: Andrew Lunn 
> Cc: Sudarsana Reddy Kalluru ;
> da...@davemloft.net; netdev@vger.kernel.org; Michal Kalderon
> ; Ariel Elior ;
> j...@resnulli.us
> Subject: [EXT] RE: [PATCH net-next 1/1] devlink: Add APIs to
> publish/unpublish the port parameters.
> 
> External Email
> 
> --
> 
> 
> > -Original Message-
> > From: Andrew Lunn 
> > Sent: Tuesday, July 2, 2019 10:19 PM
> > To: Parav Pandit 
> > Cc: Sudarsana Reddy Kalluru ;
> > da...@davemloft.net; netdev@vger.kernel.org;
> mkalde...@marvell.com;
> > ael...@marvell.com; j...@resnulli.us
> > Subject: Re: [PATCH net-next 1/1] devlink: Add APIs to
> > publish/unpublish the port parameters.
> >
> > > A vendor driver calling these APIs is needed at minimum.
> >
> > Not a vendor driver, but a mainline driver.
> >
> My apologies for terminology.
> I meant to say that a NIC/hw driver from the kernel tree that created the
> devlink port should call this API (as user) in the patch.
> You said it rightly below. Thanks.
> 
> > But yes, a new API should not be added without at least one user.
> >
> > Andrew
Thanks a lot for your reviews.
Marvell NIC driver has a requirement to support the display/configuration of 
device attributes. Sent the proposed changes with following 'subject line',
 [PATCH net-next 4/4] qed: Add devlink support for configuration attributes.
Have received a comment (from community) suggesting to move some of the 
attributes to devlink-port interface, which
requires the proposed APIs.

Will update the commit message and send it with the Marvel driver patch series 
which use this functionality.


RE: [PATCH net-next 1/1] qed: Add support for Timestamping the unicast PTP packets.

2019-07-02 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: David Miller 
> Sent: Wednesday, July 3, 2019 12:53 AM
> To: Sudarsana Reddy Kalluru 
> Cc: netdev@vger.kernel.org; Michal Kalderon ;
> Ariel Elior 
> Subject: Re: [PATCH net-next 1/1] qed: Add support for Timestamping the
> unicast PTP packets.
> 
> From: Sudarsana Reddy Kalluru 
> Date: Tue, 2 Jul 2019 08:04:12 -0700
> 
> > The register definition in the header file captures more details on
> > the individual bits.
> 
> Where is this register definition in the header file and why aren't CPP 
> defines
> from there being used instead of a mask constant mask?
> 
> Thanks.
Sorry, my mistake. taking back my statement. Will send the updated patch with 
CPP define.


[PATCH net-next 1/1] devlink: Add APIs to publish/unpublish the port parameters.

2019-07-02 Thread Sudarsana Reddy Kalluru
The patch adds devlink interfaces for drivers to publish/unpublish the
devlink port parameters.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 include/net/devlink.h |  2 ++
 net/core/devlink.c| 42 ++
 2 files changed, 44 insertions(+)

diff --git a/include/net/devlink.h b/include/net/devlink.h
index 6c51e86..2e2d7fc 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -651,6 +651,8 @@ int devlink_port_params_register(struct devlink_port 
*devlink_port,
 void devlink_port_params_unregister(struct devlink_port *devlink_port,
const struct devlink_param *params,
size_t params_count);
+void devlink_port_params_publish(struct devlink_port *devlink_port);
+void devlink_port_params_unpublish(struct devlink_port *ddevlink_port);
 int devlink_param_driverinit_value_get(struct devlink *devlink, u32 param_id,
   union devlink_param_value *init_val);
 int devlink_param_driverinit_value_set(struct devlink *devlink, u32 param_id,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 4baf716..c06c23f 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -6378,6 +6378,48 @@ void devlink_port_params_unregister(struct devlink_port 
*devlink_port,
 }
 EXPORT_SYMBOL_GPL(devlink_port_params_unregister);
 
+/**
+ * devlink_port_params_publish - publish port configuration parameters
+ *
+ * @devlink_port: devlink port
+ *
+ * Publish previously registered port configuration parameters.
+ */
+void devlink_port_params_publish(struct devlink_port *devlink_port)
+{
+   struct devlink_param_item *param_item;
+
+   list_for_each_entry(param_item, &devlink_port->param_list, list) {
+   if (param_item->published)
+   continue;
+   param_item->published = true;
+   devlink_param_notify(devlink_port->devlink, devlink_port->index,
+param_item, DEVLINK_CMD_PORT_PARAM_NEW);
+   }
+}
+EXPORT_SYMBOL_GPL(devlink_port_params_publish);
+
+/**
+ * devlink_port_params_unpublish - unpublish port configuration parameters
+ *
+ * @devlink_port: devlink port
+ *
+ * Unpublish previously registered port configuration parameters.
+ */
+void devlink_port_params_unpublish(struct devlink_port *devlink_port)
+{
+   struct devlink_param_item *param_item;
+
+   list_for_each_entry(param_item, &devlink_port->param_list, list) {
+   if (!param_item->published)
+   continue;
+   param_item->published = false;
+   devlink_param_notify(devlink_port->devlink, devlink_port->index,
+param_item, DEVLINK_CMD_PORT_PARAM_DEL);
+   }
+}
+EXPORT_SYMBOL_GPL(devlink_port_params_unpublish);
+
 static int
 __devlink_param_driverinit_value_get(struct list_head *param_list, u32 
param_id,
 union devlink_param_value *init_val)
-- 
1.8.3.1



[PATCH net-next 1/1] qed: Add support for Timestamping the unicast PTP packets.

2019-07-02 Thread Sudarsana Reddy Kalluru
This patch masks the lower 4 bits of PARAM-MASK registers as required
by the Hardware to detect/timestamp the unicast PTP packets. The register
definition in the header file captures more details on the individual bits.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_ptp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_ptp.c 
b/drivers/net/ethernet/qlogic/qed/qed_ptp.c
index f3ebdc5..4a7acfc 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ptp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ptp.c
@@ -243,7 +243,7 @@ static int qed_ptp_hw_cfg_filters(struct qed_dev *cdev,
return -EINVAL;
}
 
-   qed_wr(p_hwfn, p_ptt, NIG_REG_LLH_PTP_PARAM_MASK, 0);
+   qed_wr(p_hwfn, p_ptt, NIG_REG_LLH_PTP_PARAM_MASK, 0xF);
qed_wr(p_hwfn, p_ptt, NIG_REG_LLH_PTP_RULE_MASK, rule_mask);
qed_wr(p_hwfn, p_ptt, NIG_REG_RX_PTP_EN, enable_cfg);
 
@@ -253,7 +253,7 @@ static int qed_ptp_hw_cfg_filters(struct qed_dev *cdev,
qed_wr(p_hwfn, p_ptt, NIG_REG_TX_LLH_PTP_RULE_MASK, 0x3FFF);
} else {
qed_wr(p_hwfn, p_ptt, NIG_REG_TX_PTP_EN, enable_cfg);
-   qed_wr(p_hwfn, p_ptt, NIG_REG_TX_LLH_PTP_PARAM_MASK, 0);
+   qed_wr(p_hwfn, p_ptt, NIG_REG_TX_LLH_PTP_PARAM_MASK, 0xF);
qed_wr(p_hwfn, p_ptt, NIG_REG_TX_LLH_PTP_RULE_MASK, rule_mask);
}
 
-- 
1.8.3.1



RE: [EXT] [PATCH V4] bnx2x: Prevent ptp_task to be rescheduled indefinitely

2019-06-27 Thread Sudarsana Reddy Kalluru


> -Original Message-
> From: Guilherme G. Piccoli 
> Sent: Thursday, June 27, 2019 10:02 PM
> To: GR-everest-linux-l2 ;
> netdev@vger.kernel.org; Sudarsana Reddy Kalluru 
> Cc: Ariel Elior ; gpicc...@canonical.com;
> jay.vosbu...@canonical.com
> Subject: [EXT] [PATCH V4] bnx2x: Prevent ptp_task to be rescheduled
> indefinitely
> 
> External Email
> 
> --
> Currently bnx2x ptp worker tries to read a register with timestamp
> information in case of TX packet timestamping and in case it fails, the 
> routine
> reschedules itself indefinitely. This was reported as a kworker always at 100%
> of CPU usage, which was narrowed down to be bnx2x ptp_task.
> 
> By following the ioctl handler, we could narrow down the problem to an NTP
> tool (chrony) requesting HW timestamping from bnx2x NIC with RX filter
> zeroed; this isn't reproducible for example with ptp4l (from linuxptp) since
> this tool requests a supported RX filter.
> It seems NIC FW timestamp mechanism cannot work well with
> RX_FILTER_NONE - driver's PTP filter init routine skips a register write to 
> the
> adapter if there's not a supported filter request.
> 
> This patch addresses the problem of bnx2x ptp thread's everlasting
> reschedule by retrying the register read 10 times; between the read
> attempts the thread sleeps for an increasing amount of time starting in 1ms
> to give FW some time to perform the timestamping. If it still fails after all
> retries, we bail out in order to prevent an unbound resource consumption
> from bnx2x.
> 
> The patch also adds an ethtool statistic for accounting the skipped TX
> timestamp packets and it reduces the priority of timestamping error
> messages to prevent log flooding. The code was tested using both linuxptp
> and chrony.
> 
> Reported-and-tested-by: Przemyslaw Hausman
> 
> Suggested-by: Sudarsana Reddy Kalluru 
> Signed-off-by: Guilherme G. Piccoli 
> ---
> 
> Thanks again for your review Sudarsana. I've addressed in this V4 your
> suggestions about removing some debug messages[0].
> 
> [0] https://marc.info/?l=linux-netdev&m=156165243804760
> 
>  .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c   |  5 ++-
>  .../ethernet/broadcom/bnx2x/bnx2x_ethtool.c   |  4 ++-
>  .../net/ethernet/broadcom/bnx2x/bnx2x_main.c  | 33 ++
> -  .../net/ethernet/broadcom/bnx2x/bnx2x_stats.h |  3 ++
>  4 files changed, 34 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> index 008ad0ca89ba..c12c1bab0fe4 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> @@ -3857,9 +3857,12 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff
> *skb, struct net_device *dev)
> 
>   if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {
>   if (!(bp->flags & TX_TIMESTAMPING_EN)) {
> + bp->eth_stats.ptp_skip_tx_ts++;
>   BNX2X_ERR("Tx timestamping was not enabled, this
> packet will not be timestamped\n");
>   } else if (bp->ptp_tx_skb) {
> - BNX2X_ERR("The device supports only a single
> outstanding packet to timestamp, this packet will not be timestamped\n");
> + bp->eth_stats.ptp_skip_tx_ts++;
> + netdev_err_once(bp->dev,
> + "Device supports only a single
> outstanding packet to timestamp,
> +this packet won't be timestamped\n");
>   } else {
>   skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
>   /* schedule check for Tx timestamp */ diff --git
> a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
> b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
> index 51fc845de31a..4a0ba6801c9e 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
> @@ -182,7 +182,9 @@ static const struct {
>   { STATS_OFFSET32(driver_filtered_tx_pkt),
>   4, false, "driver_filtered_tx_pkt" },
>   { STATS_OFFSET32(eee_tx_lpi),
> - 4, true, "Tx LPI entry count"}
> + 4, true, "Tx LPI entry count"},
> + { STATS_OFFSET32(ptp_skip_tx_ts),
> + 4, false, "ptp_skipped_tx_tstamp" },
>  };
> 
>  #define BNX2X_NUM_STATS  ARRAY_SIZE(bnx2x_stats_arr)
> diff --git a/drivers/n

RE: [EXT] [PATCH V3] bnx2x: Prevent ptp_task to be rescheduled indefinitely

2019-06-27 Thread Sudarsana Reddy Kalluru


> -Original Message-
> From: Guilherme G. Piccoli 
> Sent: Thursday, June 27, 2019 1:49 AM
> To: GR-everest-linux-l2 ;
> netdev@vger.kernel.org; Sudarsana Reddy Kalluru 
> Cc: Ariel Elior ; gpicc...@canonical.com;
> jay.vosbu...@canonical.com
> Subject: [EXT] [PATCH V3] bnx2x: Prevent ptp_task to be rescheduled
> indefinitely
> 
> External Email
> 
> --
> Currently bnx2x ptp worker tries to read a register with timestamp
> information in case of TX packet timestamping and in case it fails, the 
> routine
> reschedules itself indefinitely. This was reported as a kworker always at 100%
> of CPU usage, which was narrowed down to be bnx2x ptp_task.
> 
> By following the ioctl handler, we could narrow down the problem to an NTP
> tool (chrony) requesting HW timestamping from bnx2x NIC with RX filter
> zeroed; this isn't reproducible for example with ptp4l (from linuxptp) since
> this tool requests a supported RX filter.
> It seems NIC FW timestamp mechanism cannot work well with
> RX_FILTER_NONE - driver's PTP filter init routine skips a register write to 
> the
> adapter if there's not a supported filter request.
> 
> This patch addresses the problem of bnx2x ptp thread's everlasting
> reschedule by retrying the register read 10 times; between the read
> attempts the thread sleeps for an increasing amount of time starting in 1ms
> to give FW some time to perform the timestamping. If it still fails after all
> retries, we bail out in order to prevent an unbound resource consumption
> from bnx2x.
> 
> The patch also adds an ethtool statistic for accounting the skipped TX
> timestamp packets and it reduces the priority of timestamping error
> messages to prevent log flooding. The code was tested using both linuxptp
> and chrony.
> 
> Reported-and-tested-by: Przemyslaw Hausman
> 
> Suggested-by: Sudarsana Reddy Kalluru 
> Signed-off-by: Guilherme G. Piccoli 
> ---
> 
> Sudarsana, thanks again for your feedback. I've reduced the sleep times to
> start in 1ms and goes up to 512ms - the sum of sleep times is 1023ms, but
> due to the inherent overhead in sleeping/waking-up procedure, I've
> measured the total delay in the register read loop (on bnx2x_ptp_task) to be
> ~1.6 seconds.  It is almost the 2s value you first suggested as PTP_TIMEOUT.
> 
>  .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c   | 12 +--
>  .../ethernet/broadcom/bnx2x/bnx2x_ethtool.c   |  4 ++-
>  .../net/ethernet/broadcom/bnx2x/bnx2x_main.c  | 36 ++
> -  .../net/ethernet/broadcom/bnx2x/bnx2x_stats.h |  3 ++
>  4 files changed, 43 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> index 008ad0ca89ba..6751cd04e8d8 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> @@ -3857,9 +3857,17 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff
> *skb, struct net_device *dev)
> 
>   if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {
>   if (!(bp->flags & TX_TIMESTAMPING_EN)) {
> - BNX2X_ERR("Tx timestamping was not enabled, this
> packet will not be timestamped\n");
> + bp->eth_stats.ptp_skip_tx_ts++;
> + netdev_err_once(bp->dev,
> + "Tx timestamping isn't enabled, this
> packet won't be timestamped\n");
> + DP(BNX2X_MSG_PTP,
> +"Tx timestamping isn't enabled, this packet won't
> be
> +timestamped\n");

Hitting this path is very unlikely and also PTP packets arrive once in a second 
in general. Either retain BNX2X_ERR() statement or remove the extra call 
netdev_err_once().

>   } else if (bp->ptp_tx_skb) {
> - BNX2X_ERR("The device supports only a single
> outstanding packet to timestamp, this packet will not be timestamped\n");
> + bp->eth_stats.ptp_skip_tx_ts++;
> + netdev_err_once(bp->dev,
> + "Device supports only a single
> outstanding packet to timestamp, this packet won't be timestamped\n");
> + DP(BNX2X_MSG_PTP,
> +"Device supports only a single outstanding packet to
> timestamp,
> +this packet won't be timestamped\n");
Same as above.

>   } else {
>   skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
> 

RE: [EXT] [PATCH V2] bnx2x: Prevent ptp_task to be rescheduled indefinitely

2019-06-26 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: Guilherme Piccoli 
> Sent: Wednesday, June 26, 2019 1:56 AM
> To: Sudarsana Reddy Kalluru ;
> jay.vosbu...@canonical.com
> Cc: GR-everest-linux-l2 ;
> netdev@vger.kernel.org; Ariel Elior 
> Subject: Re: [EXT] [PATCH V2] bnx2x: Prevent ptp_task to be rescheduled
> indefinitely
> 
> Sudarsana, let me ask you something: why does the register is reading value
> 0x0 always in the TX timestamp routine if the RX filter is set to None? This 
> is
> the main cause of the thread reschedule thing.

The register value of zero indicates there is no pending Tx timestamp to be 
read by the driver.
FW writes/latches the Tx timestamp for PTP event packet in this register. And 
it does the latching only if the register is free.
In this case user/app look to be requesting  the Timestamp (via skb->tx_flags) 
for non-ptp Tx packet. In the Tx path, driver schedules a thread for reading 
the Tx timestamp,
   bnx2x_start_xmit()
   {
if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) 
schedule_work(&bp->ptp_task);
   }
FW seem to be not timestamping the packet at all and driver is indefinitely 
waiting for it.

> 
> Of course this thread thing is important to fix, but I was discussing with my
> leader here and we are curious on the reasoning the register is getting 0x0.
> 
> Thanks in advance,
> 
> 
> Guilherme


RE: [EXT] Re: [PATCH net-next 4/4] qed: Add devlink support for configuration attributes.

2019-06-25 Thread Sudarsana Reddy Kalluru


> -Original Message-
> From: Jiri Pirko 
> Sent: Thursday, June 20, 2019 7:08 PM
> To: Sudarsana Reddy Kalluru 
> Cc: Jakub Kicinski ; da...@davemloft.net;
> netdev@vger.kernel.org; Michal Kalderon ; Ariel
> Elior 
> Subject: Re: [EXT] Re: [PATCH net-next 4/4] qed: Add devlink support for
> configuration attributes.
> 
> Thu, Jun 20, 2019 at 02:09:29PM CEST, skall...@marvell.com wrote:
> >> -Original Message-
> >> From: Jakub Kicinski 
> >> Sent: Tuesday, June 18, 2019 4:24 AM
> >> To: Sudarsana Reddy Kalluru 
> >> Cc: da...@davemloft.net; netdev@vger.kernel.org; Michal Kalderon
> >> ; Ariel Elior ; Jiri Pirko
> >> 
> >> Subject: [EXT] Re: [PATCH net-next 4/4] qed: Add devlink support for
> >> configuration attributes.
> >>
> >> External Email
> >>
> >> -
> >> - On Mon, 17 Jun 2019 04:45:28 -0700, Sudarsana Reddy Kalluru wrote:
> >> > This patch adds implementation for devlink callbacks for reading/
> >> > configuring the device attributes.
> >> >
> >> > Signed-off-by: Sudarsana Reddy Kalluru 
> >> > Signed-off-by: Ariel Elior 
> >>
> >> You need to provide documentation for your parameters, plus some of
> >> them look like they should potentially be port params, not device params.
> >
> >Thanks a lot for your review. Will add the required documentation. In case
> of Marvell adapter, any of the device/adapter/port parameters can be
> read/configurable via any PF (ethdev) on the port. Hence adding the
> commands at device level. Hope this is fine.
> 
> No it is not. Port param should be port param.
> 
> Also please be careful not to add any generic param as driver specific.
> 
> Thanks!
Hi,
   Could you please with my query on the devlink-port-params implementation. 
[had sent the same query earlier to j...@mellanox.com (based on the copyright 
info)].

Kernel seem to be invoking the driver devlink callbacks (registered via 
DEVLINK_PARAM_DRIVER) only when the associated parameter is published via 
devlink_params_publish(). callnback invocation path,
   devlink_nl_param_fill()
   {
if (!param_item->published)
 continue;
 ctx.cmode = i;
  err = devlink_param_get(devlink, param, &ctx);
   }
The API devlink_params_publish() publishes only the devlink-dev parameters 
(i.e., registered via devlink_params_register()), not the devlink-port params 
which are registered via devlink_port_params_register(). I couldn't find any 
other interface for publishing the devlink-port-params.
I have manually verified setting the published flag for port-params (as in 
below) and, observed that kernel correctly invokes the callbacks of 
devlink-port-params.
   list_for_each_entry(param_item, &dl_port.param_list, list) {
param_item->published = true;
  }
Please let me know if I'm missing something here or, it's a missing 
functionality in the kernel.

Thanks,
Sudarsana


RE: [EXT] [PATCH V2] bnx2x: Prevent ptp_task to be rescheduled indefinitely

2019-06-24 Thread Sudarsana Reddy Kalluru


> -Original Message-
> From: Guilherme G. Piccoli 
> Sent: Tuesday, June 25, 2019 3:54 AM
> To: GR-everest-linux-l2 ;
> netdev@vger.kernel.org; Sudarsana Reddy Kalluru 
> Cc: Ariel Elior ; gpicc...@canonical.com;
> jay.vosbu...@canonical.com
> Subject: [EXT] [PATCH V2] bnx2x: Prevent ptp_task to be rescheduled
> indefinitely
> 
> External Email
> 
> --
> Currently bnx2x ptp worker tries to read a register with timestamp
> information in case of TX packet timestamping and in case it fails, the 
> routine
> reschedules itself indefinitely. This was reported as a kworker always at 100%
> of CPU usage, which was narrowed down to be bnx2x ptp_task.
> 
> By following the ioctl handler, we could narrow down the problem to an NTP
> tool (chrony) requesting HW timestamping from bnx2x NIC with RX filter
> zeroed; this isn't reproducible for example with ptp4l (from linuxptp) since
> this tool requests a supported RX filter.
> It seems NIC FW timestamp mechanism cannot work well with
> RX_FILTER_NONE - driver's PTP filter init routine skips a register write to 
> the
> adapter if there's not a supported filter request.
> 
> This patch addresses the problem of bnx2x ptp thread's everlasting
> reschedule by retrying the register read 10 times; between the read
> attempts the thread sleeps for an increasing amount of time starting in 50ms
> to give FW some time to perform the timestamping. If it still fails after all
> retries, we bail out in order to prevent an unbound resource consumption
> from bnx2x.

Thanks for your changes and time on this. In general time-latching happens in 
couple or more milliseconds (even in some 100s of usec) under the normal 
traffic conditions. With this approach, there's a possibility that every packet 
has to wait for atleast 50ms for the timestamping. This in turn affects the 
wait-queue (of packets to be timestamped) at hardware as next TS recording 
happens only after the register is freed/read. And also, it incurs some latency 
for the ptp applications.

PTP thread is consuming time may be due to the debug messages in this error 
path, which you are planning address already (thanks!!).
   "Also, I've dropped the PTP "outstanding, etc" messages to debug-level, 
they're quite flooding my log.
Do you see cpu hog even after removing this message? In such case we may need 
to think of other alternatives such as sleep for 1 ms.

Just for the info, the approach continuous-poll-for-timestamp() is used ixgbe 
driver (ixgbe_ptp_tx_hwtstamp_work()) as well.

> 
> The patch also adds an ethtool statistic for accounting the skipped TX
> timestamp packets and it reduces the priority of timestamping error
> messages to prevent log flooding. The code was tested using both linuxptp
> and chrony.
> 
> Reported-and-tested-by: Przemyslaw Hausman
> 
> Suggested-by: Sudarsana Reddy Kalluru 
> Signed-off-by: Guilherme G. Piccoli 
> ---
> 
> Sudarsana, thanks for the suggestion! I've tried to follow an identical
> approach from [0], but still the ptp thread was consuming a lot of CPU due to
> the good amount of reschedules.
> 
> I decided then to use the loop approach with small increasing delays, in order
> to respect the time FW takes eventually to complete timestamping.
> 
> Also, I've dropped the PTP "outstanding, etc" messages to debug-level,
> they're quite flooding my log. Cheers!
> 
> [0] git.kernel.org/pub/scm/linux/kernel/git/davem/net-
> next.git/commit/?id=9adebac37e7d
> 
>  .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c   | 12 +--
>  .../ethernet/broadcom/bnx2x/bnx2x_ethtool.c   |  4 ++-
>  .../net/ethernet/broadcom/bnx2x/bnx2x_main.c  | 36 ++
> -  .../net/ethernet/broadcom/bnx2x/bnx2x_stats.h |  3 ++
>  4 files changed, 43 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> index 008ad0ca89ba..6751cd04e8d8 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> @@ -3857,9 +3857,17 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff
> *skb, struct net_device *dev)
> 
>   if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {
>   if (!(bp->flags & TX_TIMESTAMPING_EN)) {
> - BNX2X_ERR("Tx timestamping was not enabled, this
> packet will not be timestamped\n");
> + bp->eth_stats.ptp_skip_tx_ts++;
> + netdev_err_once(bp->dev,
> + "Tx timestamping isn't enabled, this
> packe

RE: [EXT] [PATCH] bnx2x: Prevent ptp_task to be rescheduled indefinitely

2019-06-22 Thread Sudarsana Reddy Kalluru


> -Original Message-
> From: Guilherme G. Piccoli 
> Sent: Saturday, June 22, 2019 2:57 AM
> To: GR-everest-linux-l2 ;
> netdev@vger.kernel.org
> Cc: Ariel Elior ; Sudarsana Reddy Kalluru
> ; gpicc...@canonical.com;
> jay.vosbu...@canonical.com
> Subject: [EXT] [PATCH] bnx2x: Prevent ptp_task to be rescheduled indefinitely
> 
> External Email
> 
> --
> Currently bnx2x ptp worker tries to read a register with timestamp
> information in case of TX packet timestamping and in case it fails, the 
> routine
> reschedules itself indefinitely. This was reported as a kworker always at 100%
> of CPU usage, which was narrowed down to be bnx2x ptp_task.
> 
> By following the ioctl handler, we could narrow down the problem to an NTP
> tool (chrony) requesting HW timestamping from bnx2x NIC with RX filter
> zeroed; this isn't reproducible for example with linuxptp since this tool
> request a supported RX filter. It seems the NIC HW timestamp mechanism
> cannot work well with RX_FILTER_NONE - in driver's PTP filter initialization
> routine, when there's not a supported filter request the function does not
> perform a specific register write to the adapter.
> 
> This patch addresses the problem of the everlasting reschedule of the ptp
> worker by limiting that to 3 attempts (the first one plus two reschedules), in
> order to prevent the unbound resource consumption from the driver. It's not
> correct behavior for a driver to not take into account potential problems in a
> routine reading a device register, be it an invalid RX filter (leading to a 
> non-
> functional HW clock) or even a potential device FW issue causing the register
> value to be wrong, hence we believe the fix is relevant to ensure proper
> driver behavior.
> 
> This has no functional change in the succeeding path of the HW
> timestamping code in the driver, only portion of code it changes is the error
> path for TX timestamping. It was tested using both linuxptp and chrony.
> 
> Reported-and-tested-by: Przemyslaw Hausman
> 
> Signed-off-by: Guilherme G. Piccoli 
> ---
>  drivers/net/ethernet/broadcom/bnx2x/bnx2x.h|  1 +
>  .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c|  1 +
>  .../net/ethernet/broadcom/bnx2x/bnx2x_main.c   | 18 +-
>  3 files changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
> b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
> index 6026b53137aa..349965135227 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
> @@ -1838,6 +1838,7 @@ struct bnx2x {
>   bool timecounter_init_done;
>   struct sk_buff *ptp_tx_skb;
>   unsigned long ptp_tx_start;
> + u8 ptp_retry_count;
>   bool hwtstamp_ioctl_called;
>   u16 tx_type;
>   u16 rx_filter;
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> index 008ad0ca89ba..990ec049f357 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
> @@ -3865,6 +3865,7 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb,
> struct net_device *dev)
>   /* schedule check for Tx timestamp */
>   bp->ptp_tx_skb = skb_get(skb);
>   bp->ptp_tx_start = jiffies;
> + bp->ptp_retry_count = 0;
>   schedule_work(&bp->ptp_task);
>   }
>   }
> diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
> b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
> index 03ac10b1cd1e..872ae672faaa 100644
> --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
> +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
> @@ -15233,16 +15233,24 @@ static void bnx2x_ptp_task(struct work_struct
> *work)
>   memset(&shhwtstamps, 0, sizeof(shhwtstamps));
>   shhwtstamps.hwtstamp = ns_to_ktime(ns);
>   skb_tstamp_tx(bp->ptp_tx_skb, &shhwtstamps);
> - dev_kfree_skb_any(bp->ptp_tx_skb);
> - bp->ptp_tx_skb = NULL;
> -
>   DP(BNX2X_MSG_PTP, "Tx timestamp, timestamp cycles =
> %llu, ns = %llu\n",
>  timestamp, ns);
> + goto clear;
>   } else {
>   DP(BNX2X_MSG_PTP, "There is no valid Tx timestamp
> yet\n");
> - /* Reschedule to keep checking for a valid timestamp value
> */
> - schedule_work(&bp->ptp_task);
> + /* Reschedule twice to check again f

RE: [EXT] Re: [PATCH net-next 4/4] qed: Add devlink support for configuration attributes.

2019-06-20 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: Jakub Kicinski 
> Sent: Tuesday, June 18, 2019 4:24 AM
> To: Sudarsana Reddy Kalluru 
> Cc: da...@davemloft.net; netdev@vger.kernel.org; Michal Kalderon
> ; Ariel Elior ; Jiri Pirko
> 
> Subject: [EXT] Re: [PATCH net-next 4/4] qed: Add devlink support for
> configuration attributes.
> 
> External Email
> 
> --
> On Mon, 17 Jun 2019 04:45:28 -0700, Sudarsana Reddy Kalluru wrote:
> > This patch adds implementation for devlink callbacks for reading/
> > configuring the device attributes.
> >
> > Signed-off-by: Sudarsana Reddy Kalluru 
> > Signed-off-by: Ariel Elior 
> 
> You need to provide documentation for your parameters, plus some of them
> look like they should potentially be port params, not device params.

Thanks a lot for your review. Will add the required documentation. In case of 
Marvell adapter, any of the device/adapter/port parameters can be 
read/configurable via any PF (ethdev) on the port. Hence adding the commands at 
device level. Hope this is fine.


RE: [PATCH net] bnx2x: Check if transceiver implements DDM before access

2019-06-17 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: David Miller 
> Sent: Monday, June 17, 2019 2:09 AM
> To: maur...@linux.vnet.ibm.com
> Cc: netdev@vger.kernel.org; Ariel Elior ; Sudarsana
> Reddy Kalluru ; GR-everest-linux-l2  linux...@marvell.com>
> Subject: Re: [PATCH net] bnx2x: Check if transceiver implements DDM before
> access
> 
> From: "Mauro S. M. Rodrigues" 
> Date: Thu, 13 Jun 2019 16:25:40 -0300
> 
> > Some transceivers may comply with SFF-8472 even though they do not
> > implement the Digital Diagnostic Monitoring (DDM) interface described
> > in the spec. The existence of such area is specified by the 6th bit of
> > byte 92, set to 1 if implemented.
> >
> > Currently, without checking this bit, bnx2x fails trying to read sfp
> > module's EEPROM with the follow message:
> >
> > ethtool -m enP5p1s0f1
> > Cannot get Module EEPROM data: Input/output error
> >
> > Because it fails to read the additional 256 bytes in which it is
> > assumed to exist the DDM data.
> >
> > This issue was noticed using a Mellanox Passive DAC PN 01FT738. The
> > EEPROM data was confirmed by Mellanox as correct and similar to other
> > Passive DACs from other manufacturers.
> >
> > Signed-off-by: Mauro S. M. Rodrigues 
> 
> Marvell folks, please review.

Acked-by: Sudarsana Reddy Kalluru 


[PATCH net-next 3/4] qed: Add new file for devlink implementation.

2019-06-17 Thread Sudarsana Reddy Kalluru
The patch introduces new files for qed devlink implementation.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/Makefile  |   3 +-
 drivers/net/ethernet/qlogic/qed/qed_devlink.c |  97 
 drivers/net/ethernet/qlogic/qed/qed_devlink.h |  18 +
 drivers/net/ethernet/qlogic/qed/qed_main.c| 102 +-
 4 files changed, 118 insertions(+), 102 deletions(-)
 create mode 100644 drivers/net/ethernet/qlogic/qed/qed_devlink.c
 create mode 100644 drivers/net/ethernet/qlogic/qed/qed_devlink.h

diff --git a/drivers/net/ethernet/qlogic/qed/Makefile 
b/drivers/net/ethernet/qlogic/qed/Makefile
index a0acb94..2e9f3cc 100644
--- a/drivers/net/ethernet/qlogic/qed/Makefile
+++ b/drivers/net/ethernet/qlogic/qed/Makefile
@@ -3,7 +3,8 @@ obj-$(CONFIG_QED) := qed.o
 
 qed-y := qed_cxt.o qed_dev.o qed_hw.o qed_init_fw_funcs.o qed_init_ops.o \
 qed_int.o qed_main.o qed_mcp.o qed_sp_commands.o qed_spq.o qed_l2.o \
-qed_selftest.o qed_dcbx.o qed_debug.o qed_ptp.o qed_mng_tlv.o
+qed_selftest.o qed_dcbx.o qed_debug.o qed_ptp.o qed_mng_tlv.o \
+qed_devlink.o
 qed-$(CONFIG_QED_SRIOV) += qed_sriov.o qed_vf.o
 qed-$(CONFIG_QED_LL2) += qed_ll2.o
 qed-$(CONFIG_QED_RDMA) += qed_roce.o qed_rdma.o qed_iwarp.o
diff --git a/drivers/net/ethernet/qlogic/qed/qed_devlink.c 
b/drivers/net/ethernet/qlogic/qed/qed_devlink.c
new file mode 100644
index 000..acb6c87
--- /dev/null
+++ b/drivers/net/ethernet/qlogic/qed/qed_devlink.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0
+#include 
+#include "qed.h"
+#include "qed_devlink.h"
+#include "qed_mcp.h"
+
+static int qed_dl_param_get(struct devlink *dl, u32 id,
+   struct devlink_param_gset_ctx *ctx)
+{
+   struct qed_devlink *qed_dl;
+   struct qed_dev *cdev;
+
+   qed_dl = devlink_priv(dl);
+   cdev = qed_dl->cdev;
+   ctx->val.vbool = cdev->iwarp_cmt;
+
+   return 0;
+}
+
+static int qed_dl_param_set(struct devlink *dl, u32 id,
+   struct devlink_param_gset_ctx *ctx)
+{
+   struct qed_devlink *qed_dl;
+   struct qed_dev *cdev;
+
+   qed_dl = devlink_priv(dl);
+   cdev = qed_dl->cdev;
+   cdev->iwarp_cmt = ctx->val.vbool;
+
+   return 0;
+}
+
+static const struct devlink_param qed_devlink_params[] = {
+   DEVLINK_PARAM_DRIVER(QED_DEVLINK_PARAM_ID_IWARP_CMT,
+"iwarp_cmt", DEVLINK_PARAM_TYPE_BOOL,
+BIT(DEVLINK_PARAM_CMODE_RUNTIME),
+qed_dl_param_get, qed_dl_param_set, NULL),
+};
+
+static const struct devlink_ops qed_dl_ops;
+
+int qed_devlink_register(struct qed_dev *cdev)
+{
+   union devlink_param_value value;
+   struct qed_devlink *qed_dl;
+   struct devlink *dl;
+   int rc;
+
+   dl = devlink_alloc(&qed_dl_ops, sizeof(*qed_dl));
+   if (!dl)
+   return -ENOMEM;
+
+   qed_dl = devlink_priv(dl);
+
+   cdev->dl = dl;
+   qed_dl->cdev = cdev;
+
+   rc = devlink_register(dl, &cdev->pdev->dev);
+   if (rc)
+   goto err_free;
+
+   rc = devlink_params_register(dl, qed_devlink_params,
+ARRAY_SIZE(qed_devlink_params));
+   if (rc)
+   goto err_unregister;
+
+   value.vbool = false;
+   devlink_param_driverinit_value_set(dl,
+  QED_DEVLINK_PARAM_ID_IWARP_CMT,
+  value);
+
+   devlink_params_publish(dl);
+   cdev->iwarp_cmt = false;
+
+   return 0;
+
+err_unregister:
+   devlink_unregister(dl);
+
+err_free:
+   cdev->dl = NULL;
+   devlink_free(dl);
+
+   return rc;
+}
+
+void qed_devlink_unregister(struct qed_dev *cdev)
+{
+   if (!cdev->dl)
+   return;
+
+   devlink_params_unregister(cdev->dl, qed_devlink_params,
+ ARRAY_SIZE(qed_devlink_params));
+
+   devlink_unregister(cdev->dl);
+   devlink_free(cdev->dl);
+}
diff --git a/drivers/net/ethernet/qlogic/qed/qed_devlink.h 
b/drivers/net/ethernet/qlogic/qed/qed_devlink.h
new file mode 100644
index 000..86e1caa
--- /dev/null
+++ b/drivers/net/ethernet/qlogic/qed/qed_devlink.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _QED_DEVLINK_H
+#define _QED_DEVLINK_H
+#include "qed.h"
+
+struct qed_devlink {
+   struct qed_dev *cdev;
+};
+
+enum qed_devlink_param_id {
+   QED_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
+   QED_DEVLINK_PARAM_ID_IWARP_CMT,
+};
+
+int qed_devlink_register(struct qed_dev *cdev);
+void qed_devlink_unregister(struct qed_dev *cdev);
+
+#endif
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index fdd84f5..e3a875

[PATCH net-next 0/4] qed: Devlink support for config attributes management.

2019-06-17 Thread Sudarsana Reddy Kalluru
The patch series adds support for managing the config attributes using
devlink interfaces.

Please consider applying it to 'net-next' tree.

Sudarsana Reddy Kalluru (4):
  qed: Add APIs for device attributes configuration.
  qed: Perform devlink registration after the hardware init.
  qed: Add new file for devlink implementation.
  qed: Add devlink support for configuration attributes.

 drivers/net/ethernet/qlogic/qed/Makefile  |   3 +-
 drivers/net/ethernet/qlogic/qed/qed.h |   1 +
 drivers/net/ethernet/qlogic/qed/qed_devlink.c | 281 ++
 drivers/net/ethernet/qlogic/qed/qed_devlink.h |  41 
 drivers/net/ethernet/qlogic/qed/qed_hsi.h |  31 +++
 drivers/net/ethernet/qlogic/qed/qed_main.c| 118 +--
 drivers/net/ethernet/qlogic/qed/qed_mcp.c |  64 ++
 drivers/net/ethernet/qlogic/qed/qed_mcp.h |  14 ++
 8 files changed, 444 insertions(+), 109 deletions(-)
 create mode 100644 drivers/net/ethernet/qlogic/qed/qed_devlink.c
 create mode 100644 drivers/net/ethernet/qlogic/qed/qed_devlink.h

-- 
1.8.3.1



[PATCH net-next 1/4] qed: Add APIs for device attributes configuration.

2019-06-17 Thread Sudarsana Reddy Kalluru
The patch adds APIs for reading/configuring the device attributes using
mailbox interfaces.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_hsi.h | 20 ++
 drivers/net/ethernet/qlogic/qed/qed_mcp.c | 64 +++
 drivers/net/ethernet/qlogic/qed/qed_mcp.h | 14 +++
 3 files changed, 98 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_hsi.h 
b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
index e054f6c..5091f5b1 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_hsi.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_hsi.h
@@ -12580,6 +12580,8 @@ struct public_drv_mb {
 #define DRV_MSG_CODE_BW_UPDATE_ACK 0x3200
 #define DRV_MSG_CODE_NIG_DRAIN 0x3000
 #define DRV_MSG_CODE_S_TAG_UPDATE_ACK  0x3b00
+#define DRV_MSG_CODE_GET_NVM_CFG_OPTION0x003e
+#define DRV_MSG_CODE_SET_NVM_CFG_OPTION0x003f
 #define DRV_MSG_CODE_INITIATE_PF_FLR0x0201
 #define DRV_MSG_CODE_VF_DISABLED_DONE  0xc000
 #define DRV_MSG_CODE_CFG_VF_MSIX   0xc001
@@ -12748,6 +12750,21 @@ struct public_drv_mb {
 #define DRV_MB_PARAM_FEATURE_SUPPORT_PORT_EEE  0x0002
 #define DRV_MB_PARAM_FEATURE_SUPPORT_FUNC_VLINK0x0001
 
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ID_SHIFT   0
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ID_MASK0x
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ALL_SHIFT  16
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ALL_MASK   0x0001
+#define DRV_MB_PARAM_NVM_CFG_OPTION_INIT_SHIFT 17
+#define DRV_MB_PARAM_NVM_CFG_OPTION_INIT_MASK  0x0002
+#define DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT_SHIFT   18
+#define DRV_MB_PARAM_NVM_CFG_OPTION_COMMIT_MASK0x0004
+#define DRV_MB_PARAM_NVM_CFG_OPTION_FREE_SHIFT 19
+#define DRV_MB_PARAM_NVM_CFG_OPTION_FREE_MASK  0x0008
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL_SHIFT   20
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL_MASK0x0010
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID_SHIFT24
+#define DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID_MASK 0x0f00
+
u32 fw_mb_header;
 #define FW_MSG_CODE_MASK   0x
 #define FW_MSG_CODE_UNSUPPORTED 0x
@@ -13319,6 +13336,9 @@ enum spad_sections {
SPAD_SECTION_MAX
 };
 
+#define NVM_CFG_ID_MAC_ADDRESS 1
+#define NVM_CFG_ID_MF_MODE 9
+
 #define MCP_TRACE_SIZE  2048   /* 2kb */
 
 /* This section is located at a fixed location in the beginning of the
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c 
b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
index 758702c..573911a 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
@@ -3750,3 +3750,67 @@ int qed_mcp_get_ppfid_bitmap(struct qed_hwfn *p_hwfn, 
struct qed_ptt *p_ptt)
 
return 0;
 }
+
+int qed_mcp_nvm_get_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
+   u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
+   u32 *p_len)
+{
+   u32 mb_param = 0, resp, param;
+   int rc;
+
+   QED_MFW_SET_FIELD(mb_param, DRV_MB_PARAM_NVM_CFG_OPTION_ID, option_id);
+   if (flags & QED_NVM_CFG_OPTION_INIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_INIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_FREE)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_FREE, 1);
+   if (flags & QED_NVM_CFG_OPTION_ENTITY_SEL) {
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL, 1);
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID,
+ entity_id);
+   }
+
+   rc = qed_mcp_nvm_rd_cmd(p_hwfn, p_ptt,
+   DRV_MSG_CODE_GET_NVM_CFG_OPTION,
+   mb_param, &resp, ¶m, p_len, (u32 *)p_buf);
+
+   return rc;
+}
+
+int qed_mcp_nvm_set_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
+   u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
+   u32 len)
+{
+   u32 mb_param = 0, resp, param;
+   int rc;
+
+   QED_MFW_SET_FIELD(mb_param, DRV_MB_PARAM_NVM_CFG_OPTION_ID, option_id);
+   if (flags & QED_NVM_CFG_OPTION_ALL)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_ALL, 1);
+   if (flags & QED_NVM_CFG_OPTION_INIT)
+   QED_MFW_SET_FIELD(mb_param,
+ DRV_MB_PARAM_NVM_CFG_OPTION_INIT, 1);
+   if (flags & QED_NVM_CFG_OPTION_COMMIT)
+ 

[PATCH net-next 2/4] qed: Perform devlink registration after the hardware init.

2019-06-17 Thread Sudarsana Reddy Kalluru
Devlink callbacks need access to device resources such as ptt lock, hence
performing the devlink registration after the device initialization.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed_main.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 829dd60..fdd84f5 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -472,22 +472,24 @@ static struct qed_dev *qed_probe(struct pci_dev *pdev,
}
DP_INFO(cdev, "PCI init completed successfully\n");
 
-   rc = qed_devlink_register(cdev);
+   rc = qed_hw_prepare(cdev, QED_PCI_DEFAULT);
if (rc) {
-   DP_INFO(cdev, "Failed to register devlink.\n");
+   DP_ERR(cdev, "hw prepare failed\n");
goto err2;
}
 
-   rc = qed_hw_prepare(cdev, QED_PCI_DEFAULT);
+   rc = qed_devlink_register(cdev);
if (rc) {
-   DP_ERR(cdev, "hw prepare failed\n");
-   goto err2;
+   DP_INFO(cdev, "Failed to register devlink.\n");
+   goto err3;
}
 
DP_INFO(cdev, "qed_probe completed successfully\n");
 
return cdev;
 
+err3:
+   qed_hw_remove(cdev);
 err2:
qed_free_pci(cdev);
 err1:
@@ -501,14 +503,14 @@ static void qed_remove(struct qed_dev *cdev)
if (!cdev)
return;
 
+   qed_devlink_unregister(cdev);
+
qed_hw_remove(cdev);
 
qed_free_pci(cdev);
 
qed_set_power_state(cdev, PCI_D3hot);
 
-   qed_devlink_unregister(cdev);
-
qed_free_cdev(cdev);
 }
 
-- 
1.8.3.1



[PATCH net-next 4/4] qed: Add devlink support for configuration attributes.

2019-06-17 Thread Sudarsana Reddy Kalluru
This patch adds implementation for devlink callbacks for reading/
configuring the device attributes.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qed/qed.h |   1 +
 drivers/net/ethernet/qlogic/qed/qed_devlink.c | 184 ++
 drivers/net/ethernet/qlogic/qed/qed_devlink.h |  23 
 drivers/net/ethernet/qlogic/qed/qed_hsi.h |  11 ++
 4 files changed, 219 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed.h 
b/drivers/net/ethernet/qlogic/qed/qed.h
index 89fe091..2afd5c7 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -866,6 +866,7 @@ struct qed_dev {
 
struct devlink  *dl;
booliwarp_cmt;
+   u8  cfg_entity_id;
 };
 
 #define NUM_OF_VFS(dev) (QED_IS_BB(dev) ? MAX_NUM_VFS_BB \
diff --git a/drivers/net/ethernet/qlogic/qed/qed_devlink.c 
b/drivers/net/ethernet/qlogic/qed/qed_devlink.c
index acb6c87..232a8c4 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_devlink.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_devlink.c
@@ -4,6 +4,30 @@
 #include "qed_devlink.h"
 #include "qed_mcp.h"
 
+static const struct qed_devlink_cfg_param cfg_params[] = {
+   {DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV, NVM_CFG_ID_ENABLE_SRIOV,
+DEVLINK_PARAM_TYPE_BOOL},
+   {QED_DEVLINK_ENTITY_ID, 0, DEVLINK_PARAM_TYPE_U8},
+   {QED_DEVLINK_DEVICE_CAPABILITIES, NVM_CFG_ID_DEVICE_CAPABILITIES,
+DEVLINK_PARAM_TYPE_U8},
+   {QED_DEVLINK_MF_MODE, NVM_CFG_ID_MF_MODE, DEVLINK_PARAM_TYPE_U8},
+   {QED_DEVLINK_DCBX_MODE, NVM_CFG_ID_DCBX_MODE, DEVLINK_PARAM_TYPE_U8},
+   {QED_DEVLINK_PREBOOT_OPROM, NVM_CFG_ID_PREBOOT_OPROM,
+DEVLINK_PARAM_TYPE_BOOL},
+   {QED_DEVLINK_PREBOOT_BOOT_PROTOCOL, NVM_CFG_ID_PREBOOT_BOOT_PROTOCOL,
+DEVLINK_PARAM_TYPE_U8},
+   {QED_DEVLINK_PREBOOT_VLAN, NVM_CFG_ID_PREBOOT_VLAN,
+DEVLINK_PARAM_TYPE_U16},
+   {QED_DEVLINK_PREBOOT_VLAN_VALUE, NVM_CFG_ID_PREBOOT_VLAN_VALUE,
+DEVLINK_PARAM_TYPE_U16},
+   {QED_DEVLINK_MBA_DELAY_TIME, NVM_CFG_ID_MBA_DELAY_TIME,
+DEVLINK_PARAM_TYPE_U8},
+   {QED_DEVLINK_MBA_SETUP_HOT_KEY, NVM_CFG_ID_MBA_SETUP_HOT_KEY,
+DEVLINK_PARAM_TYPE_U8},
+   {QED_DEVLINK_MBA_HIDE_SETUP_PROMPT, NVM_CFG_ID_MBA_HIDE_SETUP_PROMPT,
+DEVLINK_PARAM_TYPE_BOOL},
+};
+
 static int qed_dl_param_get(struct devlink *dl, u32 id,
struct devlink_param_gset_ctx *ctx)
 {
@@ -30,11 +54,171 @@ static int qed_dl_param_set(struct devlink *dl, u32 id,
return 0;
 }
 
+static int qed_dl_get_perm_cfg(struct devlink *dl, u32 id,
+  struct devlink_param_gset_ctx *ctx)
+{
+   u8 buf[QED_DL_PARAM_BUF_LEN];
+   struct qed_devlink *qed_dl;
+   int rc, cfg_idx, len = 0;
+   struct qed_hwfn *hwfn;
+   struct qed_dev *cdev;
+   struct qed_ptt *ptt;
+   u32 flags;
+
+   qed_dl = devlink_priv(dl);
+   cdev = qed_dl->cdev;
+   hwfn = QED_LEADING_HWFN(cdev);
+
+   if (id == QED_DEVLINK_ENTITY_ID) {
+   ctx->val.vu8 = cdev->cfg_entity_id;
+   return 0;
+   }
+
+   for (cfg_idx = 0; cfg_idx < ARRAY_SIZE(cfg_params); cfg_idx++)
+   if (cfg_params[cfg_idx].id == id)
+   break;
+
+   if (cfg_idx == ARRAY_SIZE(cfg_params)) {
+   DP_ERR(cdev, "Invalid command id %d\n", id);
+   return -EINVAL;
+   }
+
+   ptt = qed_ptt_acquire(hwfn);
+   if (!ptt)
+   return -EAGAIN;
+
+   memset(buf, 0, QED_DL_PARAM_BUF_LEN);
+   flags = cdev->cfg_entity_id ? QED_DL_PARAM_PF_GET_FLAGS :
+   QED_DL_PARAM_GET_FLAGS;
+   rc = qed_mcp_nvm_get_cfg(hwfn, ptt, cfg_params[cfg_idx].cmd,
+cdev->cfg_entity_id, flags, buf, &len);
+   if (rc)
+   DP_ERR(cdev, "Error = %d\n", rc);
+   else
+   memcpy(&ctx->val, buf, len);
+
+   qed_ptt_release(hwfn, ptt);
+
+   return rc;
+}
+
+static int qed_dl_set_perm_cfg(struct devlink *dl, u32 id,
+  struct devlink_param_gset_ctx *ctx)
+{
+   u8 buf[QED_DL_PARAM_BUF_LEN];
+   struct qed_devlink *qed_dl;
+   int rc, cfg_idx, len = 0;
+   struct qed_hwfn *hwfn;
+   struct qed_dev *cdev;
+   struct qed_ptt *ptt;
+   u32 flags;
+
+   qed_dl = devlink_priv(dl);
+   cdev = qed_dl->cdev;
+   hwfn = QED_LEADING_HWFN(cdev);
+
+   if (id == QED_DEVLINK_ENTITY_ID) {
+   cdev->cfg_entity_id = ctx->val.vu8;
+   return 0;
+   }
+
+   for (cfg_idx = 0; cfg_idx < ARRAY_SIZE(cfg_params); cfg_idx++)
+   if (cfg_params[cfg_idx].id == id)
+   break;
+
+   if (cfg_idx == ARR

[PATCH net-next 1/2] qed: Reduce the severity of ptp debug message.

2019-05-27 Thread Sudarsana Reddy Kalluru
PTP Tx implementation continuously polls for the availability of timestamp.
Reducing the severity of a debug message in this path to avoid filling up
the syslog buffer with this message, especially in the error scenarios. 

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Michal Kalderon 
---
 drivers/net/ethernet/qlogic/qed/qed_ptp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_ptp.c 
b/drivers/net/ethernet/qlogic/qed/qed_ptp.c
index 1302b30..f3ebdc5 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ptp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ptp.c
@@ -157,7 +157,8 @@ static int qed_ptp_hw_read_tx_ts(struct qed_dev *cdev, u64 
*timestamp)
*timestamp = 0;
val = qed_rd(p_hwfn, p_ptt, NIG_REG_TX_LLH_PTP_BUF_SEQID);
if (!(val & QED_TIMESTAMP_MASK)) {
-   DP_INFO(p_hwfn, "Invalid Tx timestamp, buf_seqid = %d\n", val);
+   DP_VERBOSE(p_hwfn, QED_MSG_DEBUG,
+  "Invalid Tx timestamp, buf_seqid = %08x\n", val);
return -EINVAL;
}
 
-- 
1.8.3.1



[PATCH net-next 2/2] qede: Handle infinite driver spinning for Tx timestamp.

2019-05-27 Thread Sudarsana Reddy Kalluru
In PTP Tx implementation, driver kept scheduling a poll thread until the
timestamp is available. In the error scenarios (e.g. app requesting the
timestamp for non-ptp packet), this thread kept waiting for the timestamp
forever.  This patch add changes to report such scenario as an error and
terminate the thread. Added a timeout of 2 seconds i.e., max time to wait
for Tx timestamp. Added a stat value ptp_skip_txts for reporting the number
of packets for which Tx timestamping is skipped. 

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Michal Kalderon 
---
 drivers/net/ethernet/qlogic/qede/qede.h |  2 ++
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c |  1 +
 drivers/net/ethernet/qlogic/qede/qede_main.c|  3 ++
 drivers/net/ethernet/qlogic/qede/qede_ptp.c | 37 -
 4 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede.h 
b/drivers/net/ethernet/qlogic/qede/qede.h
index 92fe226..b972ab0 100644
--- a/drivers/net/ethernet/qlogic/qede/qede.h
+++ b/drivers/net/ethernet/qlogic/qede/qede.h
@@ -92,6 +92,7 @@ struct qede_stats_common {
u64 non_coalesced_pkts;
u64 coalesced_bytes;
u64 link_change_count;
+   u64 ptp_skip_txts;
 
/* port */
u64 rx_64_byte_packets;
@@ -189,6 +190,7 @@ struct qede_dev {
 
const struct qed_eth_ops*ops;
struct qede_ptp *ptp;
+   u64 ptp_skip_txts;
 
struct qed_dev_eth_info dev_info;
 #define QEDE_MAX_RSS_CNT(edev) ((edev)->dev_info.num_queues)
diff --git a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c 
b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
index 8911a97..e85f9fe 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
@@ -174,6 +174,7 @@
QEDE_STAT(coalesced_bytes),
 
QEDE_STAT(link_change_count),
+   QEDE_STAT(ptp_skip_txts),
 };
 
 #define QEDE_NUM_STATS ARRAY_SIZE(qede_stats_arr)
diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c 
b/drivers/net/ethernet/qlogic/qede/qede_main.c
index a9684a8..741377b 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -390,6 +390,7 @@ void qede_fill_by_demand_stats(struct qede_dev *edev)
p_common->brb_discards = stats.common.brb_discards;
p_common->tx_mac_ctrl_frames = stats.common.tx_mac_ctrl_frames;
p_common->link_change_count = stats.common.link_change_count;
+   p_common->ptp_skip_txts = edev->ptp_skip_txts;
 
if (QEDE_IS_BB(edev)) {
struct qede_stats_bb *p_bb = &edev->stats.bb;
@@ -2232,6 +2233,8 @@ static void qede_unload(struct qede_dev *edev, enum 
qede_unload_mode mode,
if (mode != QEDE_UNLOAD_RECOVERY)
DP_NOTICE(edev, "Link is down\n");
 
+   edev->ptp_skip_txts = 0;
+
DP_INFO(edev, "Ending qede unload\n");
 }
 
diff --git a/drivers/net/ethernet/qlogic/qede/qede_ptp.c 
b/drivers/net/ethernet/qlogic/qede/qede_ptp.c
index bddb2b5..f815435 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_ptp.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_ptp.c
@@ -30,6 +30,7 @@
  * SOFTWARE.
  */
 #include "qede_ptp.h"
+#define QEDE_PTP_TX_TIMEOUT (2 * HZ)
 
 struct qede_ptp {
const struct qed_eth_ptp_ops*ops;
@@ -38,6 +39,7 @@ struct qede_ptp {
struct timecounter  tc;
struct ptp_clock*clock;
struct work_struct  work;
+   unsigned long   ptp_tx_start;
struct qede_dev *edev;
struct sk_buff  *tx_skb;
 
@@ -160,18 +162,30 @@ static void qede_ptp_task(struct work_struct *work)
struct qede_dev *edev;
struct qede_ptp *ptp;
u64 timestamp, ns;
+   bool timedout;
int rc;
 
ptp = container_of(work, struct qede_ptp, work);
edev = ptp->edev;
+   timedout = time_is_before_jiffies(ptp->ptp_tx_start +
+ QEDE_PTP_TX_TIMEOUT);
 
/* Read Tx timestamp registers */
spin_lock_bh(&ptp->lock);
rc = ptp->ops->read_tx_ts(edev->cdev, ×tamp);
spin_unlock_bh(&ptp->lock);
if (rc) {
-   /* Reschedule to keep checking for a valid timestamp value */
-   schedule_work(&ptp->work);
+   if (unlikely(timedout)) {
+   DP_INFO(edev, "Tx timestamp is not recorded\n");
+   dev_kfree_skb_any(ptp->tx_skb);
+   ptp->tx_skb = NULL;
+   clear_bit_unlock(QEDE_FLAGS_PTP_TX_IN_PRORGESS,
+&edev->flags);
+   edev->ptp_skip_txts++;
+   } else {
+  

[PATCH net-next 0/2] qed*: Fix inifinite spinning of PTP poll thread.

2019-05-27 Thread Sudarsana Reddy Kalluru
The patch series addresses an error scenario in the PTP Tx implementation.

Please consider applying it to net-next.

Sudarsana Reddy Kalluru (2):
  qed: Reduce the severity of the debug message.
  qede: Handle driver spin for Tx timestamp.

 drivers/net/ethernet/qlogic/qed/qed_ptp.c   |  3 +-
 drivers/net/ethernet/qlogic/qede/qede.h |  2 ++
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c |  1 +
 drivers/net/ethernet/qlogic/qede/qede_main.c|  3 ++
 drivers/net/ethernet/qlogic/qede/qede_ptp.c | 37 -
 5 files changed, 38 insertions(+), 8 deletions(-)

-- 
1.8.3.1



RE: bnx2x - odd behaviour

2019-04-24 Thread Sudarsana Reddy Kalluru
Hi Ian,
Thanks for the info. BCM57711E is the older version of chip. Could you 
please recreate with elink-debugs enabled (modprobe bnx2x debug=0x4) and 
provide the complete logs and the register-dump.

Thanks,
Sudarsana
> -Original Message-
> From: Ian Kumlien 
> Sent: Wednesday, April 24, 2019 8:20 PM
> To: Sudarsana Reddy Kalluru 
> Cc: Linux Kernel Network Developers ; Ariel Elior
> ; Ameen Rahman 
> Subject: Re: bnx2x - odd behaviour
> 
> On Fri, Apr 19, 2019 at 7:23 AM Sudarsana Reddy Kalluru
>  wrote:
> >
> > Hi Ian,
> > Thanks for your info. Mfw team already analyzed the "nig timer" related
> logs but can't infer anything. From the boot-code version, the device look to
> be from the older generation of Broadcom nics. Besides the elink-
> logs/register-dump, could you also share the lspci output (lspci -vvv).
> 
> Yes, this is older machines =)
> 
> Sorry for the delay in answering, there has been a holiday here, =)
> 
> lspci output:
> 02:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II
> BCM57711E 10-Gigabit PCIe
> Subsystem: Hewlett-Packard Company NC532i Dual Port 10GbE
> Multifunction BL-C Adapter
> Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop-
> ParErr+ Stepping- SERR- FastB2B- DisINTx+
> Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort-
> SERR-  Latency: 0, Cache Line Size: 64 bytes
> Interrupt: pin A routed to IRQ 41
> Region 0: Memory at fb00 (64-bit, non-prefetchable) [size=8M]
> Region 2: Memory at fa80 (64-bit, non-prefetchable) [size=8M]
> Capabilities: [48] Power Management version 3
> Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA
> PME(D0+,D1-,D2-,D3hot+,D3cold+)
> Status: D0 NoSoftRst+ PME-Enable+ DSel=0 DScale=1 PME-
> Capabilities: [50] Vital Product Data
> Product Name: HP NC532i DP 10GbE Multifunction BL-c Adapter
> Read-only fields:
> [PN] Part number: N/A
> [EC] Engineering changes: N/A
> [SN] Serial number: 0123456789
> [MN] Manufacture ID: 31 34 65 34
> [RV] Reserved: checksum good, 39 byte(s) reserved
> End
> Capabilities: [58] MSI: Enable- Count=1/8 Maskable- 64bit+
> Address:   Data: 
> Capabilities: [a0] MSI-X: Enable+ Count=17 Masked-
> Vector table: BAR=0 offset=0044
> PBA: BAR=0 offset=00441800
> Capabilities: [ac] Express (v2) Endpoint, MSI 00
> DevCap: MaxPayload 512 bytes, PhantFunc 0, Latency L0s <1us, 
> L1
> <2us
> ExtTag- AttnBtn- AttnInd- PwrInd- RBE+
> FLReset- SlotPowerLimit 0.000W
> DevCtl: Report errors: Correctable+ Non-Fatal+ Fatal+
> Unsupported+
> RlxdOrd+ ExtTag- PhantFunc- AuxPwr+ NoSnoop+
> MaxPayload 256 bytes, MaxReadReq 4096 bytes
> DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+
> AuxPwr+ TransPend-
> LnkCap: Port #0, Speed 5GT/s, Width x8, ASPM L0s L1, Exit 
> Latency
> L0s <2us, L1 <2us
> ClockPM- Surprise- LLActRep- BwNot- ASPMOptComp-
> LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- CommClk+
> ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
> LnkSta: Speed 5GT/s, Width x4, TrErr- Train- SlotClk+
> DLActive- BWMgmt- ABWMgmt-
> DevCap2: Completion Timeout: Range ABCD, TimeoutDis+, LTR-,
> OBFF Not Supported
> DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-,
> OBFF Disabled
> LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-
>  Transmit Margin: Normal Operating Range,
> EnterModifiedCompliance- ComplianceSOS-
>  Compliance De-emphasis: -6dB
> LnkSta2: Current De-emphasis Level: -6dB, 
> EqualizationComplete-,
> EqualizationPhase1-
>  EqualizationPhase2-, EqualizationPhase3-,
> LinkEqualizationRequest-
> Capabilities: [100 v1] Device Serial Number 44-1e-a1-ff-fe-45-a6-38
> Capabilities: [110 v1] Advanced Error Reporting
> UESta:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt-
> UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
> UEMsk:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt-
> UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq+ ACSViol-
> UESvrt: DLP- SDES+ TLP- FCP- CmpltTO- Cmpl

RE: bnx2x - odd behaviour

2019-04-19 Thread Sudarsana Reddy Kalluru
Hi Ian,
Thanks for your info. Mfw team already analyzed the "nig timer" related 
logs but can't infer anything. From the boot-code version, the device look to 
be from the older generation of Broadcom nics. Besides the 
elink-logs/register-dump, could you also share the lspci output (lspci -vvv).

Thanks,
Sudarsana
> -Original Message-
> From: Ian Kumlien 
> Sent: Wednesday, April 17, 2019 6:51 PM
> To: Sudarsana Reddy Kalluru 
> Cc: Linux Kernel Network Developers ; Ariel Elior
> ; Ameen Rahman 
> Subject: Re: bnx2x - odd behaviour
> 
> On Wed, Apr 17, 2019 at 3:05 PM Sudarsana Reddy Kalluru
>  wrote:
> >
> > > -Original Message-
> > > From: Ian Kumlien 
> > > Sent: Wednesday, April 17, 2019 4:32 PM
> > > To: Sudarsana Reddy Kalluru 
> > > Cc: Linux Kernel Network Developers ; Ariel
> > > Elior ; Ameen Rahman 
> > > Subject: Re: bnx2x - odd behaviour
> > >
> > > On Wed, Apr 17, 2019 at 9:58 AM Sudarsana Reddy Kalluru
> > >  wrote:
> > > >
> > > > +Ameen
> > > >
> > > > Ian,
> > > > We couldn't find the root-cause from the logs/register-dump.
> > > > Could you please load the driver with link-debugs enabled, i.e.,
> > > > modprobe
> > > bnx2x debug=0x4 or 'ethtool -s  msglvl 0x4'. And collect
> > > the complete kernel logs and the register-dump(collected before
> > > performing ifconfig-down). Please also provide the output of "ethtool -i
> ".
> > >
> > > I'll try, this is a production system...
> > >
> > > Could it be related to the gro changes for UDP that was done in 5.x?
> > >
> > Thanks for your help. I'm not sure if this is related to gro, link related 
> > code
> is handled by different component [management firmware (mfw)]. May be
> the complete logs/register-dump provide some additional pointers. There
> were some fixes in the newer version of mfw, getting the mfw version on the
> chip would help (ethtool -i  provides mfw/boot-code version).
> 
> ethtool -i enp2s0f0
> driver: bnx2x
> version: 1.712.30-0 storm 7.13.1.0
> firmware-version: bc 6.2.28 phy baa0.105
> expansion-rom-version:
> bus-info: :02:00.0
> supports-statistics: yes
> supports-test: yes
> supports-eeprom-access: yes
> supports-register-dump: yes
> supports-priv-flags: yes
> 
> What we can see in the logs (not with the linkdebug enabled) is:
> apr 12 06:22:35 localhost kernel: bnx2x :02:00.0 enp2s0f0: NIC Link is
> Down apr 12 06:22:35 localhost kernel: bond0: link status down for active
> interface enp2s0f0, disabling it in 1000 ms apr 12 06:22:35 localhost kernel:
> bnx2x :02:00.0 enp2s0f0: NIC Link is Up, 1 Mbps full duplex, Flow
> control: ON - transmit apr 12 06:22:35 localhost kernel: bond0: link status up
> again after
> 400 ms for interface enp2s0f0
> apr 12 06:22:36 localhost kernel: bnx2x:
> [bnx2x_attn_int_deasserted3:4357(enp2s0f0)]LATCHED attention
> 0x0400 (masked)
> apr 12 06:22:36 localhost kernel: bnx2x:
> [bnx2x_attn_int_deasserted3:4361(enp2s0f0)]GRC time-out 0x08004384 apr
> 12 06:22:37 localhost kernel: bnx2x:
> [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer max (1) apr 12 06:22:37
> localhost kernel: bnx2x:
> [bnx2x_attn_int_deasserted3:4357(enp2s0f0)]LATCHED attention
> 0x0400 (masked)
> apr 12 06:22:37 localhost kernel: bnx2x:
> [bnx2x_attn_int_deasserted3:4361(enp2s0f0)]GRC time-out 0x08004384 apr
> 12 06:22:38 localhost kernel: bnx2x:
> [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer max (2) apr 12 06:22:38
> localhost kernel: bnx2x:
> [bnx2x_attn_int_deasserted3:4357(enp2s0f0)]LATCHED attention
> 0x0400 (masked)
> apr 12 06:22:38 localhost kernel: bnx2x:
> [bnx2x_attn_int_deasserted3:4361(enp2s0f0)]GRC time-out 0x08004384 apr
> 12 06:22:39 localhost kernel: bnx2x:
> [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer max (3) apr 12 06:22:39
> localhost kernel: bnx2x:
> [bnx2x_attn_int_deasserted3:4357(enp2s0f0)]LATCHED attention
> 0x0400 (masked)
> apr 12 06:22:39 localhost kernel: bnx2x:
> [bnx2x_attn_int_deasserted3:4361(enp2s0f0)]GRC time-out 0x08004384 apr
> 12 06:22:40 localhost kernel: bnx2x:
> [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer max (4) apr 12 06:22:40
> localhost kernel: bnx2x:
> [bnx2x_attn_int_deasserted3:4357(enp2s0f0)]LATCHED attention
> 0x0400 (masked)
> apr 12 06:22:40 localhost kernel: bnx2x:
> [bnx2x_attn_int_deasserted3:4361(enp2s0f0)]GRC time-out 0x08004384 apr
> 12 06:22:41 localhost kernel: bnx2x:
> [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer max (5) apr 12 06:22:41
> localhost kernel: bnx2x:
> [

RE: bnx2x - odd behaviour

2019-04-17 Thread Sudarsana Reddy Kalluru
> -Original Message-
> From: Ian Kumlien 
> Sent: Wednesday, April 17, 2019 4:32 PM
> To: Sudarsana Reddy Kalluru 
> Cc: Linux Kernel Network Developers ; Ariel Elior
> ; Ameen Rahman 
> Subject: Re: bnx2x - odd behaviour
> 
> On Wed, Apr 17, 2019 at 9:58 AM Sudarsana Reddy Kalluru
>  wrote:
> >
> > +Ameen
> >
> > Ian,
> > We couldn't find the root-cause from the logs/register-dump.
> > Could you please load the driver with link-debugs enabled, i.e., modprobe
> bnx2x debug=0x4 or 'ethtool -s  msglvl 0x4'. And collect the
> complete kernel logs and the register-dump(collected before performing
> ifconfig-down). Please also provide the output of "ethtool -i ".
> 
> I'll try, this is a production system...
> 
> Could it be related to the gro changes for UDP that was done in 5.x?
>
Thanks for your help. I'm not sure if this is related to gro, link related code 
is handled by different component [management firmware (mfw)]. May be the 
complete logs/register-dump provide some additional pointers. There were some 
fixes in the newer version of mfw, getting the mfw version on the chip would 
help (ethtool -i  provides mfw/boot-code version).
 
> > Thanks,
> > Sudarsana
> > > -Original Message-
> > > From: Ian Kumlien 
> > > Sent: Friday, April 12, 2019 4:39 PM
> > > To: Sudarsana Reddy Kalluru 
> > > Cc: Linux Kernel Network Developers ; Ariel
> > > Elior 
> > > Subject: Re: bnx2x - odd behaviour
> > >
> > > On Fri, Apr 12, 2019 at 12:53 PM Sudarsana Reddy Kalluru
> > >  wrote:
> > > >
> > > > Hi Ian,
> > > >Thanks for your info/help. There's not much info in the logs
> > > > (e.g., FW
> > > traces, calltraces). Will contact our firmware team on the
> > > register-dump analysis and provide you the update.
> > >
> > > Thank you =)
> > >
> > > > Thanks,
> > > > Sudarsana
> > > > > -Original Message-
> > > > > From: Ian Kumlien 
> > > > > Sent: Friday, April 12, 2019 2:44 PM
> > > > > To: Sudarsana Reddy Kalluru 
> > > > > Cc: Linux Kernel Network Developers ;
> > > > > Ariel Elior 
> > > > > Subject: Re: bnx2x - odd behaviour
> > > > >
> > > > > Finally!
> > > > >
> > > > > Just had a machine with the same issue!
> > > > >
> > > > > On Thu, Apr 11, 2019 at 10:56 AM Ian Kumlien
> > > > > 
> > > > > wrote:
> > > > > >
> > > > > > On Thu, Apr 4, 2019 at 4:27 PM Sudarsana Reddy Kalluru
> > > > > >  wrote:
> > > > > > >
> > > > > > > Hi,
> > > > > > >We are not aware of this issue. Please collect the
> > > > > > > register dump i.e.,
> > > > > "ethtool -d " output when this issue happens (before
> > > > > performing
> > > > > link-flap) and share it for the analysis.
> > > > >
> > > > > Sent the dump separately :)


RE: bnx2x - odd behaviour

2019-04-17 Thread Sudarsana Reddy Kalluru
+Ameen

Ian,
We couldn't find the root-cause from the logs/register-dump.
Could you please load the driver with link-debugs enabled, i.e., modprobe bnx2x 
debug=0x4 or 'ethtool -s  msglvl 0x4'. And collect the complete 
kernel logs and the register-dump(collected before performing ifconfig-down). 
Please also provide the output of "ethtool -i ".

Thanks,
Sudarsana
> -Original Message-
> From: Ian Kumlien 
> Sent: Friday, April 12, 2019 4:39 PM
> To: Sudarsana Reddy Kalluru 
> Cc: Linux Kernel Network Developers ; Ariel Elior
> 
> Subject: Re: bnx2x - odd behaviour
> 
> On Fri, Apr 12, 2019 at 12:53 PM Sudarsana Reddy Kalluru
>  wrote:
> >
> > Hi Ian,
> >Thanks for your info/help. There's not much info in the logs (e.g., FW
> traces, calltraces). Will contact our firmware team on the register-dump
> analysis and provide you the update.
> 
> Thank you =)
> 
> > Thanks,
> > Sudarsana
> > > -Original Message-
> > > From: Ian Kumlien 
> > > Sent: Friday, April 12, 2019 2:44 PM
> > > To: Sudarsana Reddy Kalluru 
> > > Cc: Linux Kernel Network Developers ; Ariel
> > > Elior 
> > > Subject: Re: bnx2x - odd behaviour
> > >
> > > Finally!
> > >
> > > Just had a machine with the same issue!
> > >
> > > On Thu, Apr 11, 2019 at 10:56 AM Ian Kumlien 
> > > wrote:
> > > >
> > > > On Thu, Apr 4, 2019 at 4:27 PM Sudarsana Reddy Kalluru
> > > >  wrote:
> > > > >
> > > > > Hi,
> > > > >We are not aware of this issue. Please collect the register
> > > > > dump i.e.,
> > > "ethtool -d " output when this issue happens (before
> > > performing
> > > link-flap) and share it for the analysis.
> > >
> > > Sent the dump separately :)


[PATCH net-next 1/2] bnx2x: Replace magic numbers with macro definitions.

2019-04-16 Thread Sudarsana Reddy Kalluru
This patch performs code cleanup by defining macros for the ptp-timestamp
filters.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 50 ++--
 1 file changed, 30 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 626b491..0ebc526 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -15376,27 +15376,45 @@ static int bnx2x_enable_ptp_packets(struct bnx2x *bp)
return 0;
 }
 
+#define BNX2X_PTP_TX_ON_PARAM_MASK 0x6AA
+#define BNX2X_PTP_TX_ON_RULE_MASK 0x3EEE
+#define BNX2X_PTP_V1_L4_PARAM_MASK 0x7EE
+#define BNX2X_PTP_V1_L4_RULE_MASK 0x3FFE
+#define BNX2X_PTP_V2_L4_PARAM_MASK 0x7EA
+#define BNX2X_PTP_V2_L4_RULE_MASK 0x3FEE
+#define BNX2X_PTP_V2_L2_PARAM_MASK 0x6BF
+#define BNX2X_PTP_V2_L2_RULE_MASK 0x3EFF
+#define BNX2X_PTP_V2_PARAM_MASK 0x6AA
+#define BNX2X_PTP_V2_RULE_MASK 0x3EEE
+
 int bnx2x_configure_ptp_filters(struct bnx2x *bp)
 {
int port = BP_PORT(bp);
+   u32 param, rule;
int rc;
 
if (!bp->hwtstamp_ioctl_called)
return 0;
 
+   param = port ? NIG_REG_P1_TLLH_PTP_PARAM_MASK :
+   NIG_REG_P0_TLLH_PTP_PARAM_MASK;
+   rule = port ? NIG_REG_P1_TLLH_PTP_RULE_MASK :
+   NIG_REG_P0_TLLH_PTP_RULE_MASK;
switch (bp->tx_type) {
case HWTSTAMP_TX_ON:
bp->flags |= TX_TIMESTAMPING_EN;
-   REG_WR(bp, port ? NIG_REG_P1_TLLH_PTP_PARAM_MASK :
-  NIG_REG_P0_TLLH_PTP_PARAM_MASK, 0x6AA);
-   REG_WR(bp, port ? NIG_REG_P1_TLLH_PTP_RULE_MASK :
-  NIG_REG_P0_TLLH_PTP_RULE_MASK, 0x3EEE);
+   REG_WR(bp, param, BNX2X_PTP_TX_ON_PARAM_MASK);
+   REG_WR(bp, rule, BNX2X_PTP_TX_ON_RULE_MASK);
break;
case HWTSTAMP_TX_ONESTEP_SYNC:
BNX2X_ERR("One-step timestamping is not supported\n");
return -ERANGE;
}
 
+   param = port ? NIG_REG_P1_LLH_PTP_PARAM_MASK :
+   NIG_REG_P0_LLH_PTP_PARAM_MASK;
+   rule = port ? NIG_REG_P1_LLH_PTP_RULE_MASK :
+   NIG_REG_P0_LLH_PTP_RULE_MASK;
switch (bp->rx_filter) {
case HWTSTAMP_FILTER_NONE:
break;
@@ -15410,30 +15428,24 @@ int bnx2x_configure_ptp_filters(struct bnx2x *bp)
case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
bp->rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
/* Initialize PTP detection for UDP/IPv4 events */
-   REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_PARAM_MASK :
-  NIG_REG_P0_LLH_PTP_PARAM_MASK, 0x7EE);
-   REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_RULE_MASK :
-  NIG_REG_P0_LLH_PTP_RULE_MASK, 0x3FFE);
+   REG_WR(bp, param, BNX2X_PTP_V1_L4_PARAM_MASK);
+   REG_WR(bp, rule, BNX2X_PTP_V1_L4_RULE_MASK);
break;
case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
bp->rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
/* Initialize PTP detection for UDP/IPv4 or UDP/IPv6 events */
-   REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_PARAM_MASK :
-  NIG_REG_P0_LLH_PTP_PARAM_MASK, 0x7EA);
-   REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_RULE_MASK :
-  NIG_REG_P0_LLH_PTP_RULE_MASK, 0x3FEE);
+   REG_WR(bp, param, BNX2X_PTP_V2_L4_PARAM_MASK);
+   REG_WR(bp, rule, BNX2X_PTP_V2_L4_RULE_MASK);
break;
case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
bp->rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
/* Initialize PTP detection L2 events */
-   REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_PARAM_MASK :
-  NIG_REG_P0_LLH_PTP_PARAM_MASK, 0x6BF);
-   REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_RULE_MASK :
-  NIG_REG_P0_LLH_PTP_RULE_MASK, 0x3EFF);
+   REG_WR(bp, param, BNX2X_PTP_V2_L2_PARAM_MASK);
+   REG_WR(bp, rule, BNX2X_PTP_V2_L2_RULE_MASK);
 
break;
case HWTSTAMP_FILTER_PTP_V2_EVENT:
@@ -15441,10 +15453,8 @@ int bnx2x_configure_ptp_filters(struct bnx2x *bp)
case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
bp->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
/* Initialize PTP detection L2, UDP/IPv4 or UDP/IPv6 events */
-   REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_PARAM_MASK :
-  NIG_REG_P0_LLH_PTP_PARAM_MASK, 0x6AA);
-   REG_WR(bp, port ? NIG_REG_P1_LLH_PTP_RULE_MASK :
-  NI

[PATCH net-next 2/2] bnx2x: Add support for detection of P2P event packets.

2019-04-16 Thread Sudarsana Reddy Kalluru
The patch adds support for detecting the P2P (peer-to-peer) event packets.
This is required for timestamping the PTP packets in peer delay mode.
Unmask the below bits (set to 0) for device to detect the p2p packets.
  NIG_REG_P0/1_LLH_PTP_PARAM_MASK
  NIG_REG_P0/1_TLLH_PTP_PARAM_MASK
bit 1 - IPv4 DA 1 of 224.0.0.107.
bit 3 - IPv6 DA 1 of 0xFF02:0:0:0:0:0:0:6B.
bit 9 - MAC DA 1 of 0x01-80-C2-00-00-0E.
  NIG_REG_P0/1_LLH_PTP_RULE_MASK
  NIG_REG_P0/1_TLLH_PTP_RULE_MASK
bit 2 - {IPv4 DA 1; UDP DP 0}
bit 6 - MAC Ethertype 0 of 0x88F7.
bit 9 - MAC DA 1 of 0x01-80-C2-00-00-0E.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 0ebc526..0d6c98a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -15376,16 +15376,18 @@ static int bnx2x_enable_ptp_packets(struct bnx2x *bp)
return 0;
 }
 
-#define BNX2X_PTP_TX_ON_PARAM_MASK 0x6AA
-#define BNX2X_PTP_TX_ON_RULE_MASK 0x3EEE
-#define BNX2X_PTP_V1_L4_PARAM_MASK 0x7EE
-#define BNX2X_PTP_V1_L4_RULE_MASK 0x3FFE
-#define BNX2X_PTP_V2_L4_PARAM_MASK 0x7EA
-#define BNX2X_PTP_V2_L4_RULE_MASK 0x3FEE
-#define BNX2X_PTP_V2_L2_PARAM_MASK 0x6BF
-#define BNX2X_PTP_V2_L2_RULE_MASK 0x3EFF
-#define BNX2X_PTP_V2_PARAM_MASK 0x6AA
-#define BNX2X_PTP_V2_RULE_MASK 0x3EEE
+#define BNX2X_P2P_DETECT_PARAM_MASK 0x5F5
+#define BNX2X_P2P_DETECT_RULE_MASK 0x3DBB
+#define BNX2X_PTP_TX_ON_PARAM_MASK (BNX2X_P2P_DETECT_PARAM_MASK & 0x6AA)
+#define BNX2X_PTP_TX_ON_RULE_MASK (BNX2X_P2P_DETECT_RULE_MASK & 0x3EEE)
+#define BNX2X_PTP_V1_L4_PARAM_MASK (BNX2X_P2P_DETECT_PARAM_MASK & 0x7EE)
+#define BNX2X_PTP_V1_L4_RULE_MASK (BNX2X_P2P_DETECT_RULE_MASK & 0x3FFE)
+#define BNX2X_PTP_V2_L4_PARAM_MASK (BNX2X_P2P_DETECT_PARAM_MASK & 0x7EA)
+#define BNX2X_PTP_V2_L4_RULE_MASK (BNX2X_P2P_DETECT_RULE_MASK & 0x3FEE)
+#define BNX2X_PTP_V2_L2_PARAM_MASK (BNX2X_P2P_DETECT_PARAM_MASK & 0x6BF)
+#define BNX2X_PTP_V2_L2_RULE_MASK (BNX2X_P2P_DETECT_RULE_MASK & 0x3EFF)
+#define BNX2X_PTP_V2_PARAM_MASK (BNX2X_P2P_DETECT_PARAM_MASK & 0x6AA)
+#define BNX2X_PTP_V2_RULE_MASK (BNX2X_P2P_DETECT_RULE_MASK & 0x3EEE)
 
 int bnx2x_configure_ptp_filters(struct bnx2x *bp)
 {
-- 
1.8.3.1



[PATCH net-next 0/2] bnx2x: Support for timestamping in P2P mode.

2019-04-16 Thread Sudarsana Reddy Kalluru
The patch series adds driver support for timestamping the ptp packets
in peer-delay (P2P) mode.
 - Patch (1) performs the code cleanup.
 - Patch (2) adds the required implementation.

Please consider applying it 'net-next' tree.

Sudarsana Reddy Kalluru (2):
  bnx2x: Replace magic numbers with macro definitions.
  bnx2x: Add support for detection of P2P event packets.

 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 52 +++-
 1 file changed, 32 insertions(+), 20 deletions(-)

-- 
1.8.3.1



RE: bnx2x - odd behaviour

2019-04-12 Thread Sudarsana Reddy Kalluru
Hi Ian,
   Thanks for your info/help. There's not much info in the logs (e.g., FW 
traces, calltraces). Will contact our firmware team on the register-dump 
analysis and provide you the update.

Thanks,
Sudarsana
> -Original Message-
> From: Ian Kumlien 
> Sent: Friday, April 12, 2019 2:44 PM
> To: Sudarsana Reddy Kalluru 
> Cc: Linux Kernel Network Developers ; Ariel Elior
> 
> Subject: Re: bnx2x - odd behaviour
> 
> Finally!
> 
> Just had a machine with the same issue!
> 
> On Thu, Apr 11, 2019 at 10:56 AM Ian Kumlien 
> wrote:
> >
> > On Thu, Apr 4, 2019 at 4:27 PM Sudarsana Reddy Kalluru
> >  wrote:
> > >
> > > Hi,
> > >We are not aware of this issue. Please collect the register dump i.e.,
> "ethtool -d " output when this issue happens (before performing
> link-flap) and share it for the analysis.
> 
> Sent the dump separately :)


RE: bnx2x - odd behaviour

2019-04-04 Thread Sudarsana Reddy Kalluru
Hi,
   We are not aware of this issue. Please collect the register dump i.e., 
"ethtool -d " output when this issue happens (before performing 
link-flap) and share it for the analysis.

Thanks,
Sudarsana
> -Original Message-
> From: netdev-ow...@vger.kernel.org  On
> Behalf Of Ian Kumlien
> Sent: Wednesday, April 3, 2019 8:31 PM
> To: Linux Kernel Network Developers ; Ariel Elior
> ; Sudarsana Reddy Kalluru 
> Subject: bnx2x - odd behaviour
> 
> Hi,
> 
> We just had this happen on 5.0.2
> 
> It looks like the interface went down, ended up in a broken state and a ip li
> set down/up dev enp2s0f0 made it work again
> 
> It looks really weird and I haven't really seen anything like it, anyone with 
> a
> clue?
> 
> dmesg:
> 
> [1310361.808694] bnx2x :02:00.0 enp2s0f0: NIC Link is Down
> [1310361.824554] bond0: link status down for active interface enp2s0f0,
> disabling it in 1000 ms [1310362.872678] bond0: link status definitely down
> for interface enp2s0f0, disabling it [1310362.880691] device enp2s0f0 left
> promiscuous mode [1310363.188592] bnx2x :02:00.0 enp2s0f0: NIC Link
> is Up, 1 Mbps full duplex, Flow control: ON - transmit [1310363.200653]
> bond0: link status up for interface enp2s0f0, enabling it in 0 ms
> [1310363.208192] bond0: link status definitely up for interface enp2s0f0,
> 1 Mbps full duplex [1310363.216885] bond0: making interface enp2s0f0
> the new active one [1310363.223075] device enp2s0f0 entered promiscuous
> mode [1310363.228613] bond0: first active interface up!
> [1310364.048805] bnx2x:
> [bnx2x_attn_int_deasserted3:4357(enp2s0f0)]LATCHED attention
> 0x0400 (masked)
> [1310364.058297] bnx2x: [bnx2x_attn_int_deasserted3:4361(enp2s0f0)]GRC
> time-out 0x08004384
> [1310365.072604] bnx2x: [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer
> max (1) [1310366.096679] bnx2x:
> [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer max (2) [1310366.103922]
> bnx2x:
> [bnx2x_attn_int_deasserted3:4357(enp2s0f0)]LATCHED attention
> 0x0400 (masked)
> [1310366.113387] bnx2x: [bnx2x_attn_int_deasserted3:4361(enp2s0f0)]GRC
> time-out 0x08004384
> [1310367.120518] bnx2x: [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer
> max (3) [1310368.144635] bnx2x:
> [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer max (4) [1310369.168591]
> bnx2x: [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer max (5)
> [1310371.216519] bnx2x: [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer
> max (6) ... it does go on ...
> [1312156.028230] bnx2x: [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer
> max (1520) [1312157.052226] bnx2x:
> [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer max (1521)
> [1312157.059842] bnx2x:
> [bnx2x_attn_int_deasserted3:4357(enp2s0f0)]LATCHED attention
> 0x0400 (masked)
> [1312157.069242] bnx2x: [bnx2x_attn_int_deasserted3:4361(enp2s0f0)]GRC
> time-out 0x08004384
> [1312158.076261] bnx2x:
> [bnx2x_attn_int_deasserted3:4357(enp2s0f0)]LATCHED attention
> 0x0400 (masked)
> [1312158.085657] bnx2x: [bnx2x_attn_int_deasserted3:4361(enp2s0f0)]GRC
> time-out 0x08004384
> [1312159.100154] bnx2x: [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer
> max (1522) [1312160.124226] bnx2x:
> [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer max (1523)
> [1312161.148127] bnx2x: [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer
> max (1524) [1312162.172102] bnx2x:
> [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer max (1525)
> [1312163.196000] bnx2x: [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer
> max (1526) [1312163.203610] bnx2x:
> [bnx2x_attn_int_deasserted3:4357(enp2s0f0)]LATCHED attention
> 0x0400 (masked)
> [1312163.213082] bnx2x: [bnx2x_attn_int_deasserted3:4361(enp2s0f0)]GRC
> time-out 0x08004384
> [1312164.220248] bnx2x: [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer
> max (1527) [1312165.244119] bnx2x:
> [bnx2x_attn_int_deasserted3:4357(enp2s0f0)]LATCHED attention
> 0x0400 (masked)
> [1312165.253524] bnx2x: [bnx2x_attn_int_deasserted3:4361(enp2s0f0)]GRC
> time-out 0x08004384
> [1312166.268053] bnx2x: [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer
> max (1528) [1312167.292105] bnx2x:
> [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer max (1529)
> [1312168.316022] bnx2x: [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer
> max (1530) [1312169.340014] bnx2x:
> [bnx2x_hw_stats_update:869(enp2s0f0)]NIG timer max (1531)
> [1312169.347584] bnx2x:
> [bnx2x_attn_int_deasserted3:4357(enp2s0f0)]LATCHED attention
> 0x0400 (masked)
> [1312169.357054] bnx2x: [bnx2x_attn_int_deasserted3:4361(enp2s0f0)]GRC
> time-out 0x08004384
> 
> ... trying to bing it down ...
> 
> [1312169.659992] bond0: link status down for active interface enp2s0f0,
> disabling it in 1000 ms [1312169.672041] bond0: link st

[PATCH net-next 1/1] bnx2x: Utilize FW 7.13.11.0.

2019-03-27 Thread Sudarsana Reddy Kalluru
Commit 8fcf0ec44c11f "bnx2x: Add FW 7.13.11.0" added said .bin FW to
linux-firmware; This patch incorporates the FW in the bnx2x driver.
This introduces few FW fixes and the support for Tx VLAN filtering.

Please consider applying it to 'net-next' tree.
 
Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h | 21 ++---
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h 
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
index d9057c8..78326a6 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
@@ -3024,7 +3024,7 @@ struct afex_stats {
 
 #define BCM_5710_FW_MAJOR_VERSION  7
 #define BCM_5710_FW_MINOR_VERSION  13
-#define BCM_5710_FW_REVISION_VERSION   1
+#define BCM_5710_FW_REVISION_VERSION   11
 #define BCM_5710_FW_ENGINEERING_VERSION0
 #define BCM_5710_FW_COMPILE_FLAGS  1
 
@@ -3639,8 +3639,10 @@ struct client_init_rx_data {
 #define CLIENT_INIT_RX_DATA_TPA_EN_IPV6_SHIFT 1
 #define CLIENT_INIT_RX_DATA_TPA_MODE (0x1<<2)
 #define CLIENT_INIT_RX_DATA_TPA_MODE_SHIFT 2
-#define CLIENT_INIT_RX_DATA_RESERVED5 (0x1F<<3)
-#define CLIENT_INIT_RX_DATA_RESERVED5_SHIFT 3
+#define CLIENT_INIT_RX_DATA_TPA_OVER_VLAN_DISABLE (0x1<<3)
+#define CLIENT_INIT_RX_DATA_TPA_OVER_VLAN_DISABLE_SHIFT 3
+#define CLIENT_INIT_RX_DATA_RESERVED5 (0xF<<4)
+#define CLIENT_INIT_RX_DATA_RESERVED5_SHIFT 4
u8 vmqueue_mode_en_flg;
u8 extra_data_over_sgl_en_flg;
u8 cache_line_alignment_log_size;
@@ -3831,7 +3833,7 @@ struct eth_classify_cmd_header {
  */
 struct eth_classify_header {
u8 rule_cnt;
-   u8 reserved0;
+   u8 warning_on_error;
__le16 reserved1;
__le32 echo;
 };
@@ -4752,6 +4754,8 @@ struct tpa_update_ramrod_data {
__le32 sge_page_base_hi;
__le16 sge_pause_thr_low;
__le16 sge_pause_thr_high;
+   u8 tpa_over_vlan_disable;
+   u8 reserved[7];
 };
 
 
@@ -4946,7 +4950,7 @@ struct fairness_vars_per_port {
u32 upper_bound;
u32 fair_threshold;
u32 fairness_timeout;
-   u32 reserved0;
+   u32 size_thr;
 };
 
 /*
@@ -5415,7 +5419,9 @@ struct function_start_data {
u8 sd_vlan_force_pri_val;
u8 c2s_pri_tt_valid;
u8 c2s_pri_default;
-   u8 reserved2[6];
+   u8 tx_vlan_filtering_enable;
+   u8 tx_vlan_filtering_use_pvid;
+   u8 reserved2[4];
struct c2s_pri_trans_table_entry c2s_pri_trans_table;
 };
 
@@ -5448,7 +5454,8 @@ struct function_update_data {
u8 reserved1;
__le16 sd_vlan_tag;
__le16 sd_vlan_eth_type;
-   __le16 reserved0;
+   u8 tx_vlan_filtering_pvid_change_flg;
+   u8 reserved0;
__le32 reserved2;
 };
 
-- 
1.8.3.1



RE: [PATCH net-next 0/2] qed* enhancements.

2019-03-20 Thread Sudarsana Reddy Kalluru


> -Original Message-
> From: David Miller 
> Sent: Wednesday, March 20, 2019 11:44 PM
> To: Sudarsana Reddy Kalluru 
> Cc: netdev@vger.kernel.org; Ariel Elior ; Michal
> Kalderon 
> Subject: Re: [PATCH net-next 0/2] qed* enhancements.
> 
> From: Sudarsana Reddy Kalluru 
> Date: Wed, 20 Mar 2019 00:26:24 -0700
> 
> > The patch series adds couple of enhancements for qed/qede drivers.
> > Please consider applying it to 'net-next' tree.
> >
> > Sudarsana Reddy Kalluru (2):
> >   qede: Populate mbi version in ethtool driver query data.
> >   qed: Define new MF bit for no_vlan config
> 
> Series appied.
> 
> I don't know how big your MBI version strings are, but if you are printing now
> both it and the MFW versions into that one string you might hit the
> ETHTOOL_FWVERS_LEN limit often.
> 
> Just a thought...

Dave,
   Thanks for your comments and accepting the changes. Size of mbi version 
string is 7 bytes and the mfw is 10 bytes. Hence the total string size 
including the spaces would be under ETHTOOL_FWVERS_LEN.

Thanks,
Sudarsana


[PATCH net-next 2/2] qed: Define new MF bit for no_vlan config

2019-03-20 Thread Sudarsana Reddy Kalluru
The patch introduces a new Multi-Function bit for cases where firmware
shouldn't perform the insertion of vlan-0 tag. The new bit is defined to
abstract the implementation from the actual MF mode.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
Signed-off-by: Michal Kalderon 
---
 drivers/net/ethernet/qlogic/qed/qed.h  | 3 +++
 drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 4 +---
 drivers/net/ethernet/qlogic/qed/qed_dev.c  | 6 --
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed.h 
b/drivers/net/ethernet/qlogic/qed/qed.h
index 43a57ec..512186a 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -492,6 +492,9 @@ enum qed_mf_mode_bit {
 
/* Allow DSCP to TC mapping */
QED_MF_DSCP_TO_TC_MAP,
+
+   /* Do not insert a vlan tag with id 0 */
+   QED_MF_DONT_ADD_VLAN0_TAG,
 };
 
 enum qed_ufp_mode {
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c 
b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
index 69966df..5c6a276 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
@@ -204,9 +204,7 @@ static bool qed_dcbx_roce_v2_tlv(u32 app_info_bitmap, u16 
proto_id, bool ieee)
else
p_data->arr[type].update = DONT_UPDATE_DCB_DSCP;
 
-   /* Do not add vlan tag 0 when DCB is enabled and port in UFP/OV mode */
-   if ((test_bit(QED_MF_8021Q_TAGGING, &p_hwfn->cdev->mf_bits) ||
-test_bit(QED_MF_8021AD_TAGGING, &p_hwfn->cdev->mf_bits)))
+   if (test_bit(QED_MF_DONT_ADD_VLAN0_TAG, &p_hwfn->cdev->mf_bits))
p_data->arr[type].dont_add_vlan0 = true;
 
/* QM reconf data */
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 9df8c4b..1955737 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -3157,12 +3157,14 @@ static int qed_hw_get_nvm_info(struct qed_hwfn *p_hwfn, 
struct qed_ptt *p_ptt)
cdev->mf_bits = BIT(QED_MF_OVLAN_CLSS) |
BIT(QED_MF_LLH_PROTO_CLSS) |
BIT(QED_MF_UFP_SPECIFIC) |
-   BIT(QED_MF_8021Q_TAGGING);
+   BIT(QED_MF_8021Q_TAGGING) |
+   BIT(QED_MF_DONT_ADD_VLAN0_TAG);
break;
case NVM_CFG1_GLOB_MF_MODE_BD:
cdev->mf_bits = BIT(QED_MF_OVLAN_CLSS) |
BIT(QED_MF_LLH_PROTO_CLSS) |
-   BIT(QED_MF_8021AD_TAGGING);
+   BIT(QED_MF_8021AD_TAGGING) |
+   BIT(QED_MF_DONT_ADD_VLAN0_TAG);
break;
case NVM_CFG1_GLOB_MF_MODE_NPAR1_0:
cdev->mf_bits = BIT(QED_MF_LLH_MAC_CLSS) |
-- 
1.8.3.1



[PATCH net-next 0/2] qed* enhancements.

2019-03-20 Thread Sudarsana Reddy Kalluru
The patch series adds couple of enhancements for qed/qede drivers.
Please consider applying it to 'net-next' tree.

Sudarsana Reddy Kalluru (2):
  qede: Populate mbi version in ethtool driver query data.
  qed: Define new MF bit for no_vlan config

 drivers/net/ethernet/qlogic/qed/qed.h   |  3 +++
 drivers/net/ethernet/qlogic/qed/qed_dcbx.c  |  4 +---
 drivers/net/ethernet/qlogic/qed/qed_dev.c   |  6 --
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 24 +++-
 4 files changed, 27 insertions(+), 10 deletions(-)

-- 
1.8.3.1



[PATCH net-next 1/2] qede: Populate mbi version in ethtool driver query data.

2019-03-20 Thread Sudarsana Reddy Kalluru
The patch adds support to display MBI image version in 'ethtool -i' output.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
Signed-off-by: Michal Kalderon 
---
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 24 +++-
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c 
b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
index c623808..8447a8c 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
@@ -652,9 +652,9 @@ static void qede_get_drvinfo(struct net_device *ndev,
 {
char mfw[ETHTOOL_FWVERS_LEN], storm[ETHTOOL_FWVERS_LEN];
struct qede_dev *edev = netdev_priv(ndev);
+   char mbi[ETHTOOL_FWVERS_LEN];
 
strlcpy(info->driver, "qede", sizeof(info->driver));
-   strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
 
snprintf(storm, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
 edev->dev_info.common.fw_major,
@@ -668,13 +668,27 @@ static void qede_get_drvinfo(struct net_device *ndev,
 (edev->dev_info.common.mfw_rev >> 8) & 0xFF,
 edev->dev_info.common.mfw_rev & 0xFF);
 
-   if ((strlen(storm) + strlen(mfw) + strlen("mfw storm  ")) <
-   sizeof(info->fw_version)) {
+   if ((strlen(storm) + strlen(DRV_MODULE_VERSION) + strlen("[storm]  ")) <
+   sizeof(info->version))
+   snprintf(info->version, sizeof(info->version),
+"%s [storm %s]", DRV_MODULE_VERSION, storm);
+   else
+   snprintf(info->version, sizeof(info->version),
+"%s %s", DRV_MODULE_VERSION, storm);
+
+   if (edev->dev_info.common.mbi_version) {
+   snprintf(mbi, ETHTOOL_FWVERS_LEN, "%d.%d.%d",
+(edev->dev_info.common.mbi_version &
+ QED_MBI_VERSION_2_MASK) >> QED_MBI_VERSION_2_OFFSET,
+(edev->dev_info.common.mbi_version &
+ QED_MBI_VERSION_1_MASK) >> QED_MBI_VERSION_1_OFFSET,
+(edev->dev_info.common.mbi_version &
+ QED_MBI_VERSION_0_MASK) >> QED_MBI_VERSION_0_OFFSET);
snprintf(info->fw_version, sizeof(info->fw_version),
-"mfw %s storm %s", mfw, storm);
+"mbi %s [mfw %s]", mbi, mfw);
} else {
snprintf(info->fw_version, sizeof(info->fw_version),
-"%s %s", mfw, storm);
+"mfw %s", mfw);
}
 
strlcpy(info->bus_info, pci_name(edev->pdev), sizeof(info->bus_info));
-- 
1.8.3.1



[PATCH net-next 2/2] qed: Define new MF bit for no_vlan config

2019-03-11 Thread Sudarsana Reddy Kalluru
The patch introduces a new Multi-Function bit for cases where firmware
shouldn't perform the insertion of vlan-0 tag. The new bit is defined to
abstract the implementation from the actual MF mode.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
Signed-off-by: Michal Kalderon 
---
 drivers/net/ethernet/qlogic/qed/qed.h  | 3 +++
 drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 4 +---
 drivers/net/ethernet/qlogic/qed/qed_dev.c  | 6 --
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed.h 
b/drivers/net/ethernet/qlogic/qed/qed.h
index 43a57ec..512186a 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -492,6 +492,9 @@ enum qed_mf_mode_bit {
 
/* Allow DSCP to TC mapping */
QED_MF_DSCP_TO_TC_MAP,
+
+   /* Do not insert a vlan tag with id 0 */
+   QED_MF_DONT_ADD_VLAN0_TAG,
 };
 
 enum qed_ufp_mode {
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c 
b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
index 69966df..5c6a276 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c
@@ -204,9 +204,7 @@ static bool qed_dcbx_roce_v2_tlv(u32 app_info_bitmap, u16 
proto_id, bool ieee)
else
p_data->arr[type].update = DONT_UPDATE_DCB_DSCP;
 
-   /* Do not add vlan tag 0 when DCB is enabled and port in UFP/OV mode */
-   if ((test_bit(QED_MF_8021Q_TAGGING, &p_hwfn->cdev->mf_bits) ||
-test_bit(QED_MF_8021AD_TAGGING, &p_hwfn->cdev->mf_bits)))
+   if (test_bit(QED_MF_DONT_ADD_VLAN0_TAG, &p_hwfn->cdev->mf_bits))
p_data->arr[type].dont_add_vlan0 = true;
 
/* QM reconf data */
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 9df8c4b..1955737 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -3157,12 +3157,14 @@ static int qed_hw_get_nvm_info(struct qed_hwfn *p_hwfn, 
struct qed_ptt *p_ptt)
cdev->mf_bits = BIT(QED_MF_OVLAN_CLSS) |
BIT(QED_MF_LLH_PROTO_CLSS) |
BIT(QED_MF_UFP_SPECIFIC) |
-   BIT(QED_MF_8021Q_TAGGING);
+   BIT(QED_MF_8021Q_TAGGING) |
+   BIT(QED_MF_DONT_ADD_VLAN0_TAG);
break;
case NVM_CFG1_GLOB_MF_MODE_BD:
cdev->mf_bits = BIT(QED_MF_OVLAN_CLSS) |
BIT(QED_MF_LLH_PROTO_CLSS) |
-   BIT(QED_MF_8021AD_TAGGING);
+   BIT(QED_MF_8021AD_TAGGING) |
+   BIT(QED_MF_DONT_ADD_VLAN0_TAG);
break;
case NVM_CFG1_GLOB_MF_MODE_NPAR1_0:
cdev->mf_bits = BIT(QED_MF_LLH_MAC_CLSS) |
-- 
1.8.3.1



[PATCH net-next 0/2] qed* enhancements.

2019-03-11 Thread Sudarsana Reddy Kalluru
The patch series adds couple of enhancements for qed/qede drivers.
Please consider applying it to 'net-next' tree.

Sudarsana Reddy Kalluru (2):
  qede: Populate mbi version in ethtool driver query data.
  qed: Define new MF bit for no_vlan config

 drivers/net/ethernet/qlogic/qed/qed.h   |  3 +++
 drivers/net/ethernet/qlogic/qed/qed_dcbx.c  |  4 +---
 drivers/net/ethernet/qlogic/qed/qed_dev.c   |  6 --
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 24 +++-
 4 files changed, 27 insertions(+), 10 deletions(-)

-- 
1.8.3.1



[PATCH net-next 1/2] qede: Populate mbi version in ethtool driver query data.

2019-03-11 Thread Sudarsana Reddy Kalluru
The patch adds support to display MBI image version in 'ethtool -i' output.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
Signed-off-by: Michal Kalderon 
---
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 24 +++-
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c 
b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
index c623808..8447a8c 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
@@ -652,9 +652,9 @@ static void qede_get_drvinfo(struct net_device *ndev,
 {
char mfw[ETHTOOL_FWVERS_LEN], storm[ETHTOOL_FWVERS_LEN];
struct qede_dev *edev = netdev_priv(ndev);
+   char mbi[ETHTOOL_FWVERS_LEN];
 
strlcpy(info->driver, "qede", sizeof(info->driver));
-   strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
 
snprintf(storm, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
 edev->dev_info.common.fw_major,
@@ -668,13 +668,27 @@ static void qede_get_drvinfo(struct net_device *ndev,
 (edev->dev_info.common.mfw_rev >> 8) & 0xFF,
 edev->dev_info.common.mfw_rev & 0xFF);
 
-   if ((strlen(storm) + strlen(mfw) + strlen("mfw storm  ")) <
-   sizeof(info->fw_version)) {
+   if ((strlen(storm) + strlen(DRV_MODULE_VERSION) + strlen("[storm]  ")) <
+   sizeof(info->version))
+   snprintf(info->version, sizeof(info->version),
+"%s [storm %s]", DRV_MODULE_VERSION, storm);
+   else
+   snprintf(info->version, sizeof(info->version),
+"%s %s", DRV_MODULE_VERSION, storm);
+
+   if (edev->dev_info.common.mbi_version) {
+   snprintf(mbi, ETHTOOL_FWVERS_LEN, "%d.%d.%d",
+(edev->dev_info.common.mbi_version &
+ QED_MBI_VERSION_2_MASK) >> QED_MBI_VERSION_2_OFFSET,
+(edev->dev_info.common.mbi_version &
+ QED_MBI_VERSION_1_MASK) >> QED_MBI_VERSION_1_OFFSET,
+(edev->dev_info.common.mbi_version &
+ QED_MBI_VERSION_0_MASK) >> QED_MBI_VERSION_0_OFFSET);
snprintf(info->fw_version, sizeof(info->fw_version),
-"mfw %s storm %s", mfw, storm);
+"mbi %s [mfw %s]", mbi, mfw);
} else {
snprintf(info->fw_version, sizeof(info->fw_version),
-"%s %s", mfw, storm);
+"mfw %s", mfw);
}
 
strlcpy(info->bus_info, pci_name(edev->pdev), sizeof(info->bus_info));
-- 
1.8.3.1



[PATCH net 1/1] qede: Fix internal loopback failure with jumbo mtu configuration

2019-03-07 Thread Sudarsana Reddy Kalluru
Driver uses port-mtu as packet-size for the loopback traffic. This patch
limits the max packet size to 1.5K to avoid data being split over multiple
buffer descriptors (BDs) in cases where MTU > PAGE_SIZE.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Ariel Elior 
---
 drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c 
b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
index 16331c6..3ec2de4 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c
@@ -1654,8 +1654,11 @@ static int qede_selftest_run_loopback(struct qede_dev 
*edev, u32 loopback_mode)
/* Wait for loopback configuration to apply */
msleep_interruptible(500);
 
-   /* prepare the loopback packet */
-   pkt_size = edev->ndev->mtu + ETH_HLEN;
+   /* Setting max packet size to 1.5K to avoid data being split over
+* multiple BDs in cases where MTU > PAGE_SIZE.
+*/
+   pkt_size = (((edev->ndev->mtu < ETH_DATA_LEN) ?
+edev->ndev->mtu : ETH_DATA_LEN) + ETH_HLEN);
 
skb = netdev_alloc_skb(edev->ndev, pkt_size);
if (!skb) {
-- 
1.8.3.1



[PATCH net-next 1/1] qed: Read device port count from the shmem

2019-02-21 Thread Sudarsana Reddy Kalluru
Read port count from the shared memory instead of driver deriving this
value. This change simplifies the driver implementation and also avoids
any dependencies for finding the port-count.

Signed-off-by: Sudarsana Reddy Kalluru 
Signed-off-by: Michal Kalderon 
---
 drivers/net/ethernet/qlogic/qed/qed.h |  6 +-
 drivers/net/ethernet/qlogic/qed/qed_dev.c | 95 ---
 drivers/net/ethernet/qlogic/qed/qed_l2.c  |  4 +-
 drivers/net/ethernet/qlogic/qed/qed_mcp.h |  4 --
 drivers/net/ethernet/qlogic/qed/qed_ptp.c |  2 +-
 5 files changed, 44 insertions(+), 67 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed.h 
b/drivers/net/ethernet/qlogic/qed/qed.h
index 2d21c94..43a57ec 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -753,6 +753,7 @@ struct qed_dev {
 #define CHIP_BOND_ID_SHIFT  0
 
u8  num_engines;
+   u8  num_ports;
u8  num_ports_in_engine;
u8  num_funcs_in_port;
 
@@ -892,7 +893,6 @@ void qed_configure_vp_wfq_on_link_change(struct qed_dev 
*cdev,
 
 void qed_clean_wfq_db(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
 int qed_device_num_engines(struct qed_dev *cdev);
-int qed_device_get_port_id(struct qed_dev *cdev);
 void qed_set_fw_mac_addr(__le16 *fw_msb,
 __le16 *fw_mid, __le16 *fw_lsb, u8 *mac);
 
@@ -939,6 +939,10 @@ void qed_db_recovery_execute(struct qed_hwfn *p_hwfn,
writel((u32)val, (void __iomem *)((u8 __iomem *)\
  (cdev->doorbells) + (db_addr)))
 
+#define MFW_PORT(_p_hwfn)   ((_p_hwfn)->abs_pf_id %
  \
+ qed_device_num_ports((_p_hwfn)->cdev))
+int qed_device_num_ports(struct qed_dev *cdev);
+
 /* Prototypes */
 int qed_fill_dev_info(struct qed_dev *cdev,
  struct qed_dev_info *dev_info);
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index e2cbd77..9df8c4b 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -3269,55 +3269,43 @@ static void qed_get_num_funcs(struct qed_hwfn *p_hwfn, 
struct qed_ptt *p_ptt)
   p_hwfn->enabled_func_idx, p_hwfn->num_funcs_on_engine);
 }
 
-static void qed_hw_info_port_num_bb(struct qed_hwfn *p_hwfn,
-   struct qed_ptt *p_ptt)
-{
-   u32 port_mode;
-
-   port_mode = qed_rd(p_hwfn, p_ptt, CNIG_REG_NW_PORT_MODE_BB);
-
-   if (port_mode < 3) {
-   p_hwfn->cdev->num_ports_in_engine = 1;
-   } else if (port_mode <= 5) {
-   p_hwfn->cdev->num_ports_in_engine = 2;
-   } else {
-   DP_NOTICE(p_hwfn, "PORT MODE: %d not supported\n",
- p_hwfn->cdev->num_ports_in_engine);
-
-   /* Default num_ports_in_engine to something */
-   p_hwfn->cdev->num_ports_in_engine = 1;
-   }
-}
-
-static void qed_hw_info_port_num_ah(struct qed_hwfn *p_hwfn,
-   struct qed_ptt *p_ptt)
+static void qed_hw_info_port_num(struct qed_hwfn *p_hwfn, struct qed_ptt 
*p_ptt)
 {
-   u32 port;
-   int i;
-
-   p_hwfn->cdev->num_ports_in_engine = 0;
+   u32 addr, global_offsize, global_addr, port_mode;
+   struct qed_dev *cdev = p_hwfn->cdev;
 
-   for (i = 0; i < MAX_NUM_PORTS_K2; i++) {
-   port = qed_rd(p_hwfn, p_ptt,
- CNIG_REG_NIG_PORT0_CONF_K2 + (i * 4));
-   if (port & 1)
-   p_hwfn->cdev->num_ports_in_engine++;
+   /* In CMT there is always only one port */
+   if (cdev->num_hwfns > 1) {
+   cdev->num_ports_in_engine = 1;
+   cdev->num_ports = 1;
+   return;
}
 
-   if (!p_hwfn->cdev->num_ports_in_engine) {
-   DP_NOTICE(p_hwfn, "All NIG ports are inactive\n");
-
-   /* Default num_ports_in_engine to something */
-   p_hwfn->cdev->num_ports_in_engine = 1;
+   /* Determine the number of ports per engine */
+   port_mode = qed_rd(p_hwfn, p_ptt, MISC_REG_PORT_MODE);
+   switch (port_mode) {
+   case 0x0:
+   cdev->num_ports_in_engine = 1;
+   break;
+   case 0x1:
+   cdev->num_ports_in_engine = 2;
+   break;
+   case 0x2:
+   cdev->num_ports_in_engine = 4;
+   break;
+   default:
+   DP_NOTICE(p_hwfn, "Unknown port mode 0x%08x\n", port_mode);
+   cdev->num_ports_in_engine = 1;  /* Default to something */
+   break;
}
-}
 
-static void qed_hw_info_port_num(struct qe

  1   2   3   >