net: hinic3: Fix code styles
Subsystems (4)
Fan Gong
maintainercover net: hinic3: Fix code styles
This patchset provides 4 code styles fixes:
Remove empty lines between error handling. Remove defensive txq_num check.
Use array_size instead of multiplying.
SQ use SQ_CTXT_PREF_CI_HI to improve readability.
Changes:
PATCH V01: https://lore.kernel.org/netdev/[email protected]/
PATCH V02: https://lore.kernel.org/netdev/[email protected]/
* Send "Fix netif_queue_set_napi queue_index parameter passing error" to net (Jakub Kicinski)
PATCH V03:
* Modify commit description to be more accurate and clear (Simon Horman)
Fan Gong (15):
hinic3: Add command queue detailed-respone interfaces
hinic3: Add Command Queue/Async Event Queue/Mailbox dump interfaces
hinic3: Add chip_present_flag checks to prevent errors when card is
absent
hinic3: Add RX GRO and VLAN offload support
hinic3: Add msg_send_lock for message sending concurrecy
hinic3: Add PF device support and function type validation
hinic3: Add PF FLR wait and timeout handling
hinic3: Add PF/VF capability parsing and parameter validation
hinic3: Add ethtool basic ops
hinic3: Add ethtool queue ops
hinic3: Add ethtool statistic ops
hinic3: Add ethtool coalesce ops
hinic3: Add ethtool rss ops
hinic3: Add MTU size validation
hinic3: Config netdev->watchdog_timeo to set nic tx timeout
drivers/net/ethernet/huawei/hinic3/Makefile | 1 + .../net/ethernet/huawei/hinic3/hinic3_cmdq.c | 225 ++- .../net/ethernet/huawei/hinic3/hinic3_cmdq.h | 15 + .../ethernet/huawei/hinic3/hinic3_common.h | 1 + .../net/ethernet/huawei/hinic3/hinic3_csr.h | 2 + .../net/ethernet/huawei/hinic3/hinic3_eqs.c | 67 + .../net/ethernet/huawei/hinic3/hinic3_eqs.h | 6 + .../ethernet/huawei/hinic3/hinic3_ethtool.c | 1217 +++++++++++++++++ .../ethernet/huawei/hinic3/hinic3_hw_cfg.c | 53 +- .../ethernet/huawei/hinic3/hinic3_hw_cfg.h | 8 + .../ethernet/huawei/hinic3/hinic3_hw_comm.c | 65 + .../ethernet/huawei/hinic3/hinic3_hw_comm.h | 2 + .../ethernet/huawei/hinic3/hinic3_hw_intf.h | 25 +- .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 11 + .../net/ethernet/huawei/hinic3/hinic3_hwdev.h | 1 + .../net/ethernet/huawei/hinic3/hinic3_hwif.c | 31 +- .../net/ethernet/huawei/hinic3/hinic3_irq.c | 3 +- .../net/ethernet/huawei/hinic3/hinic3_lld.c | 1 + .../net/ethernet/huawei/hinic3/hinic3_main.c | 10 + .../net/ethernet/huawei/hinic3/hinic3_mbox.c | 35 +- .../net/ethernet/huawei/hinic3/hinic3_mbox.h | 2 + .../huawei/hinic3/hinic3_mgmt_interface.h | 55 +- .../huawei/hinic3/hinic3_netdev_ops.c | 76 +- .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 167 +++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 219 +++ .../ethernet/huawei/hinic3/hinic3_nic_dev.h | 30 + .../ethernet/huawei/hinic3/hinic3_nic_io.h | 4 + .../huawei/hinic3/hinic3_pci_id_tbl.h | 1 + .../net/ethernet/huawei/hinic3/hinic3_rss.c | 487 ++++++- .../net/ethernet/huawei/hinic3/hinic3_rss.h | 19 + .../net/ethernet/huawei/hinic3/hinic3_rx.c | 84 +- .../net/ethernet/huawei/hinic3/hinic3_rx.h | 17 + .../net/ethernet/huawei/hinic3/hinic3_tx.c | 72 +- .../net/ethernet/huawei/hinic3/hinic3_tx.h | 2 + 34 files changed, 2985 insertions(+), 29 deletions(-) create mode 100644 drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c
base-commit: f77c7b96014471f2c39823ed9fcb42967e7d9ede
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 1/15 hinic3: Add command queue detailed-respone interfaces
--- .../net/ethernet/huawei/hinic3/hinic3_cmdq.c | 196 +++++++++++++++++- .../net/ethernet/huawei/hinic3/hinic3_cmdq.h | 15 ++ 2 files changed, 209 insertions(+), 2 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c +194 -2
@@ -61,6 +61,10 @@#define CMDQ_DB_HEAD_SET (val, member) \ FIELD_PREP(CMDQ_DB_HEAD_##member##_MASK, val) +#define SAVED_DATA_ARM_MASK BIT(31) +#define SAVED_DATA_SET (val, member) \ + FIELD_PREP(SAVED_DATA_##member##_MASK, val) +#define CMDQ_CEQE_TYPE_MASK GENMASK(2, 0)#define CMDQ_CEQE_GET (val, member) \ FIELD_GET(CMDQ_CEQE_##member##_MASK, le32_to_cpu(val))
@@ -84,6 +88,10 @@ enum cmdq_data_format { CMDQ_DATA_DIRECT = 1, }; +enum cmdq_scmd_type { +CMDQ_SET_ARM_CMD =2 , +}; +enum cmdq_ctrl_sect_len {CMDQ_CTRL_SECT_LEN =1 ,CMDQ_CTRL_DIRECT_SECT_LEN =2 ,
@@ -166,6 +174,11 @@ static void cmdq_clear_cmd_buf(struct hinic3_cmdq_cmd_info *cmd_info,hinic3_free_cmd_buf (hwdev, cmd_info->buf_in); cmd_info->buf_in =NULL ; } + +if (cmd_info->buf_out) { +hinic3_free_cmd_buf (hwdev, cmd_info->buf_out); + cmd_info->buf_out =NULL ; + } } static void clear_wqe_complete_bit(struct hinic3_cmdq *cmdq,
@@ -189,6 +202,20 @@ static void clear_wqe_complete_bit(struct hinic3_cmdq *cmdq,hinic3_wq_put_wqebbs (&cmdq->wq,CMDQ_WQE_NUM_WQEBBS ); } +static int cmdq_arm_ceq_handler (struct hinic3_cmdq *cmdq, +struct cmdq_wqe *wqe,u16 ci) +{ +struct cmdq_ctrl *ctrl = &wqe->wqe_scmd.ctrl; +__le32 ctrl_info = ctrl->ctrl_info; + +if (!CMDQ_WQE_COMPLETED (ctrl_info)) +return -EBUSY ; + +clear_wqe_complete_bit (cmdq, wqe, ci); + +return 0 ; +} +static void cmdq_update_cmd_status (struct hinic3_cmdq *cmdq,u16 prod_idx,struct cmdq_wqe *wqe) {
@@ -257,6 +284,11 @@ void hinic3_cmdq_ceq_handler(struct hinic3_hwdev *hwdev, __le32 ceqe_data)cmdq_clear_cmd_buf (cmd_info, hwdev);clear_wqe_complete_bit (cmdq, wqe, ci);break ; +case HINIC3_CMD_TYPE_SET_ARM : +/* arm_bit was set until here */ +if (cmdq_arm_ceq_handler (cmdq, wqe, ci)) +return ; +break ;default :/* only arm bit is using scmd wqe, * the other wqe is lcmd
@@ -283,6 +315,18 @@ void hinic3_cmdq_ceq_handler(struct hinic3_hwdev *hwdev, __le32 ceqe_data) } } +static int cmdq_params_valid (const struct hinic3_hwdev *hwdev, +const struct hinic3_cmd_buf *buf_in) +{ +if (le16_to_cpu (buf_in->size) >CMDQ_BUF_SIZE ) { +dev_err (hwdev->dev,"Invalid CMDQ buffer size: 0x%x\n" , + buf_in->size); +return -EINVAL ; + } + +return 0 ; +} +static int wait_cmdqs_enable (struct hinic3_cmdqs *cmdqs) {unsigned long end;
@@ -356,6 +400,7 @@ static void cmdq_prepare_wqe_ctrl(struct cmdq_wqe *wqe, u8 wrapped, enum cmdq_bufdesc_len buf_len) {struct cmdq_header *hdr =CMDQ_WQE_HEADER (wqe); +__le32 saved_data = hdr->saved_data;enum cmdq_ctrl_sect_len ctrl_len;struct cmdq_wqe_lcmd *wqe_lcmd;struct cmdq_wqe_scmd *wqe_scmd;
@@ -386,6 +431,11 @@ static void cmdq_prepare_wqe_ctrl(struct cmdq_wqe *wqe, u8 wrapped,CMDQ_WQE_HDR_SET (3 ,COMPLETE_SECT_LEN ) |CMDQ_WQE_HDR_SET (ctrl_len,CTRL_LEN ) | CMDQ_WQE_HDR_SET(wrapped, HW_BUSY_BIT)); + + saved_data &= ~cpu_to_le32 (SAVED_DATA_ARM_MASK ); +if (cmd ==CMDQ_SET_ARM_CMD && mod ==MGMT_MOD_COMM ) + saved_data |=cpu_to_le32 (SAVED_DATA_SET (1 ,ARM )); + hdr->saved_data = saved_data; } static void cmdq_set_lcmd_wqe(struct cmdq_wqe *wqe,
@@ -557,11 +607,118 @@ static int cmdq_sync_cmd_direct_resp(struct hinic3_cmdq *cmdq, u8 mod, u8 cmd,return err ? err : errcode; } +static int cmdq_sync_cmd_detail_resp (struct hinic3_cmdq *cmdq,u8 mod,u8 cmd, +struct hinic3_cmd_buf *buf_in, +struct hinic3_cmd_buf *buf_out, +__le64 *out_param) +{ +struct hinic3_cmdq_cmd_info *cmd_info, saved_cmd_info; +struct cmdq_wqe *curr_wqe, wqe = {}; +int cmpt_code =CMDQ_SEND_CMPT_CODE ; +struct hinic3_wq *wq = &cmdq->wq; +u16 curr_prod_idx, next_prod_idx; +struct completion done; +u64 curr_msg_id; +int errcode; +u8 wrapped; +int err; + +spin_lock_bh (&cmdq->cmdq_lock); + curr_wqe =cmdq_get_wqe (wq, &curr_prod_idx); +if (!curr_wqe) { +spin_unlock_bh (&cmdq->cmdq_lock); +return -EBUSY ; + } + + wrapped = cmdq->wrapped; + + next_prod_idx = curr_prod_idx +CMDQ_WQE_NUM_WQEBBS ; +if (next_prod_idx >= wq->q_depth) { + cmdq->wrapped ^=1 ; + next_prod_idx -= wq->q_depth; + } + + cmd_info = &cmdq->cmd_infos[curr_prod_idx]; + +init_completion (&done); +refcount_inc (&buf_in->ref_cnt); +refcount_inc (&buf_out->ref_cnt); + cmd_info->cmd_type =HINIC3_CMD_TYPE_SGE_RESP ; + cmd_info->done = &done; + cmd_info->errcode = &errcode; + cmd_info->direct_resp = out_param; + cmd_info->cmpt_code = &cmpt_code; + cmd_info->buf_in = buf_in; + cmd_info->buf_out = buf_out; + + saved_cmd_info = *cmd_info; +cmdq_set_lcmd_wqe (&wqe,CMDQ_CMD_SGE_RESP , buf_in, buf_out, + wrapped, mod, cmd, curr_prod_idx); +cmdq_wqe_fill (curr_wqe, &wqe); + cmd_info->cmdq_msg_id++; + curr_msg_id = cmd_info->cmdq_msg_id; + +cmdq_set_db (cmdq, cmdq->cmdq_type, next_prod_idx); +spin_unlock_bh (&cmdq->cmdq_lock); + + err =wait_cmdq_sync_cmd_completion (cmdq, cmd_info, &saved_cmd_info, + curr_msg_id, curr_prod_idx, + curr_wqe,CMDQ_CMD_TIMEOUT ); +if (err) { +dev_err (cmdq->hwdev->dev, +"Cmdq sync command timeout, mod: %u, cmd: %u, prod idx: 0x%x\n" , + mod, cmd, curr_prod_idx); + err = -ETIMEDOUT ; + } + +if (cmpt_code ==CMDQ_FORCE_STOP_CMPT_CODE ) { +dev_dbg (cmdq->hwdev->dev, +"Force stop cmdq cmd, mod: %u, cmd: %u\n" , + mod, cmd); + err = -EAGAIN ; + } + +smp_rmb ();/* read error code after completion */ + +return err ? err : errcode; +} + +int hinic3_cmd_buf_pair_init (struct hinic3_hwdev *hwdev, +struct hinic3_cmd_buf_pair *pair) +{ + pair->in =hinic3_alloc_cmd_buf (hwdev); +if (!pair->in) + goto err_out; + + pair->out =hinic3_alloc_cmd_buf (hwdev); +if (!pair->out) + goto err_free_cmd_buf_in; + +return 0 ; + +err_free_cmd_buf_in: +hinic3_free_cmd_buf (hwdev, pair->in); +err_out: +return -ENOMEM ; +} + +void hinic3_cmd_buf_pair_uninit (struct hinic3_hwdev *hwdev, +struct hinic3_cmd_buf_pair *pair) +{ +hinic3_free_cmd_buf (hwdev, pair->in); +hinic3_free_cmd_buf (hwdev, pair->out); +} +int hinic3_cmdq_direct_resp (struct hinic3_hwdev *hwdev,u8 mod,u8 cmd,struct hinic3_cmd_buf *buf_in,__le64 *out_param) {struct hinic3_cmdqs *cmdqs;int err; + err =cmdq_params_valid (hwdev, buf_in); +if (err) { +dev_err (hwdev->dev,"Invalid CMDQ parameters\n" ); + goto err_out; + } cmdqs = hwdev->cmdqs; err =wait_cmdqs_enable (cmdqs);
@@ -573,6 +730,39 @@ int hinic3_cmdq_direct_resp(struct hinic3_hwdev *hwdev, u8 mod, u8 cmd, err =cmdq_sync_cmd_direct_resp (&cmdqs->cmdq[HINIC3_CMDQ_SYNC ], mod, cmd, buf_in, out_param); +return 0 ; + +err_out: +return err; +} + +int hinic3_cmdq_detail_resp (struct hinic3_hwdev *hwdev,u8 mod,u8 cmd, +struct hinic3_cmd_buf *buf_in, +struct hinic3_cmd_buf *buf_out,__le64 *out_param) +{ +struct hinic3_cmdqs *cmdqs; +int err; + + err =cmdq_params_valid (hwdev, buf_in); +if (err) + goto err_out; + + cmdqs = hwdev->cmdqs; + + err =wait_cmdqs_enable (cmdqs); +if (err) { +dev_err (hwdev->dev,"Cmdq is disabled\n" ); + goto err_out; + } + + err =cmdq_sync_cmd_detail_resp (&cmdqs->cmdq[HINIC3_CMDQ_SYNC ], + mod, cmd, buf_in, buf_out, out_param); +if (err) + goto err_out; + +return 0 ; + +err_out:return err; }
@@ -759,7 +949,8 @@ static int init_cmdqs(struct hinic3_hwdev *hwdev)static void cmdq_flush_sync_cmd (struct hinic3_cmdq_cmd_info *cmd_info) { -if (cmd_info->cmd_type !=HINIC3_CMD_TYPE_DIRECT_RESP ) +if (cmd_info->cmd_type !=HINIC3_CMD_TYPE_DIRECT_RESP && + cmd_info->cmd_type !=HINIC3_CMD_TYPE_SGE_RESP )return ; cmd_info->cmd_type =HINIC3_CMD_TYPE_FORCE_STOP ;
@@ -786,7 +977,8 @@ static void hinic3_cmdq_flush_cmd(struct hinic3_cmdq *cmdq)while (cmdq_read_wqe (&cmdq->wq, &ci)) {hinic3_wq_put_wqebbs (&cmdq->wq,CMDQ_WQE_NUM_WQEBBS ); cmd_info = &cmdq->cmd_infos[ci]; -if (cmd_info->cmd_type ==HINIC3_CMD_TYPE_DIRECT_RESP ) +if (cmd_info->cmd_type ==HINIC3_CMD_TYPE_DIRECT_RESP || + cmd_info->cmd_type ==HINIC3_CMD_TYPE_SGE_RESP )cmdq_flush_sync_cmd (cmd_info); }spin_unlock_bh (&cmdq->cmdq_lock);
drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.h +15 -0
@@ -85,7 +85,9 @@ enum hinic3_cmdq_status {enum hinic3_cmdq_cmd_type {HINIC3_CMD_TYPE_NONE , +HINIC3_CMD_TYPE_SET_ARM ,HINIC3_CMD_TYPE_DIRECT_RESP , +HINIC3_CMD_TYPE_SGE_RESP ,HINIC3_CMD_TYPE_FAKE_TIMEOUT ,HINIC3_CMD_TYPE_TIMEOUT ,HINIC3_CMD_TYPE_FORCE_STOP ,
@@ -98,6 +100,11 @@ struct hinic3_cmd_buf {refcount_t ref_cnt; }; +struct hinic3_cmd_buf_pair { +struct hinic3_cmd_buf *in; +struct hinic3_cmd_buf *out; +}; +struct hinic3_cmdq_cmd_info {enum hinic3_cmdq_cmd_type cmd_type;struct completion *done;
@@ -107,6 +114,7 @@ struct hinic3_cmdq_cmd_info {__le64 *direct_resp;u64 cmdq_msg_id;struct hinic3_cmd_buf *buf_in; +struct hinic3_cmd_buf *buf_out; };struct hinic3_cmdq {
@@ -146,8 +154,15 @@ void hinic3_free_cmd_buf(struct hinic3_hwdev *hwdev, struct hinic3_cmd_buf *cmd_buf);void hinic3_cmdq_ceq_handler (struct hinic3_hwdev *hwdev,__le32 ceqe_data); +int hinic3_cmd_buf_pair_init (struct hinic3_hwdev *hwdev, +struct hinic3_cmd_buf_pair *pair); +void hinic3_cmd_buf_pair_uninit (struct hinic3_hwdev *hwdev, +struct hinic3_cmd_buf_pair *pair);int hinic3_cmdq_direct_resp (struct hinic3_hwdev *hwdev,u8 mod,u8 cmd,struct hinic3_cmd_buf *buf_in,__le64 *out_param); +int hinic3_cmdq_detail_resp (struct hinic3_hwdev *hwdev,u8 mod,u8 cmd, +struct hinic3_cmd_buf *buf_in, +struct hinic3_cmd_buf *buf_out,__le64 *out_param);void hinic3_cmdq_flush_sync_cmd (struct hinic3_hwdev *hwdev);int hinic3_reinit_cmdq_ctxts (struct hinic3_hwdev *hwdev);
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 2/15 hinic3: Add Command Queue/Async Event Queue/Mailbox dump interfaces
In reply to Fan Gong--- .../net/ethernet/huawei/hinic3/hinic3_cmdq.c | 19 ++++++ .../net/ethernet/huawei/hinic3/hinic3_csr.h | 2 + .../net/ethernet/huawei/hinic3/hinic3_eqs.c | 67 +++++++++++++++++++ .../net/ethernet/huawei/hinic3/hinic3_eqs.h | 6 ++ .../net/ethernet/huawei/hinic3/hinic3_mbox.c | 15 +++++ 5 files changed, 109 insertions(+)
drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c +19 -0
@@ -6,12 +6,14 @@#include <linux/dma-mapping.h> #include "hinic3_cmdq.h" +#include "hinic3_eqs.h" #include "hinic3_hwdev.h" #include "hinic3_hwif.h" #include "hinic3_mbox.h" #define CMDQ_BUF_SIZE 2048#define CMDQ_WQEBB_SIZE 64 +#define CMDQ_WQE_HEAD_LEN 32#define CMDQ_CMD_TIMEOUT 5000#define CMDQ_ENABLE_WAIT_TIMEOUT 300
@@ -114,6 +116,20 @@ enum cmdq_cmd_type {#define CMDQ_WQE_NUM_WQEBBS 1 +static void hinic3_dump_cmdq_wqe_head (struct hinic3_hwdev *hwdev, +struct cmdq_wqe *wqe) +{ +u32 *data = (u32 *)wqe; +u32 i; + +for (i =0 ; i < (CMDQ_WQE_HEAD_LEN /sizeof (u32)); i +=0x4 ) { +dev_dbg (hwdev->dev, +"wqe data: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n" , + *(data + i), *(data + i +0x1 ), *(data + i +0x2 ), + *(data + i +0x3 )); + } +} +static struct cmdq_wqe *cmdq_read_wqe (struct hinic3_wq *wq,u16 *ci) {if (hinic3_wq_get_used (wq) ==0 )
@@ -279,6 +295,7 @@ void hinic3_cmdq_ceq_handler(struct hinic3_hwdev *hwdev, __le32 ceqe_data)case HINIC3_CMD_TYPE_TIMEOUT :dev_warn (hwdev->dev,"Cmdq timeout, q_id: %u, ci: %u\n" , cmdq_type, ci); +hinic3_dump_cmdq_wqe_head (hwdev, wqe); fallthrough;case HINIC3_CMD_TYPE_FAKE_TIMEOUT :cmdq_clear_cmd_buf (cmd_info, hwdev);
@@ -535,6 +552,8 @@ static int wait_cmdq_sync_cmd_completion(struct hinic3_cmdq *cmdq,clear_cmd_info (cmd_info, saved_cmd_info);spin_unlock_bh (&cmdq->cmdq_lock); +hinic3_dump_ceq_info (cmdq->hwdev); +return err; }
drivers/net/ethernet/huawei/hinic3/hinic3_csr.h +2 -0
@@ -76,9 +76,11 @@#define HINIC3_CSR_AEQ_CTRL_0_ADDR (HINIC3_CFG_REGS_FLAG + 0x200)#define HINIC3_CSR_AEQ_CTRL_1_ADDR (HINIC3_CFG_REGS_FLAG + 0x204) +#define HINIC3_CSR_AEQ_CONS_IDX_ADDR (HINIC3_CFG_REGS_FLAG + 0x208)#define HINIC3_CSR_AEQ_PROD_IDX_ADDR (HINIC3_CFG_REGS_FLAG + 0x20C)#define HINIC3_CSR_AEQ_CI_SIMPLE_INDIR_ADDR (HINIC3_CFG_REGS_FLAG + 0x50) +#define HINIC3_CSR_CEQ_CONS_IDX_ADDR (HINIC3_CFG_REGS_FLAG + 0x288)#define HINIC3_CSR_CEQ_PROD_IDX_ADDR (HINIC3_CFG_REGS_FLAG + 0x28c)#define HINIC3_CSR_CEQ_CI_SIMPLE_INDIR_ADDR (HINIC3_CFG_REGS_FLAG + 0x54)
drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c +67 -0
88 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_eqs.h +6 -0
@@ -56,6 +56,9 @@ struct hinic3_eq {u16 msix_entry_idx;char irq_name[HINIC3_EQ_IRQ_NAME_LEN ];struct work_struct aeq_work; + +u64 hard_intr_jif; +u64 soft_intr_jif; };struct hinic3_aeq_elem {
@@ -110,6 +113,8 @@ int hinic3_aeq_register_cb(struct hinic3_hwdev *hwdev, hinic3_aeq_event_cb hwe_cb);void hinic3_aeq_unregister_cb (struct hinic3_hwdev *hwdev,enum hinic3_aeq_type event); +void hinic3_dump_aeq_info (struct hinic3_hwdev *hwdev); +int hinic3_ceqs_init (struct hinic3_hwdev *hwdev,u16 num_ceqs,struct msix_entry *msix_entries);void hinic3_ceqs_free (struct hinic3_hwdev *hwdev);
@@ -118,5 +123,6 @@ int hinic3_ceq_register_cb(struct hinic3_hwdev *hwdev, hinic3_ceq_event_cb callback);void hinic3_ceq_unregister_cb (struct hinic3_hwdev *hwdev,enum hinic3_ceq_event event); +void hinic3_dump_ceq_info (struct hinic3_hwdev *hwdev);#endif
drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c +15 -0
@@ -5,6 +5,7 @@#include "hinic3_common.h" #include "hinic3_csr.h" +#include "hinic3_eqs.h" #include "hinic3_hwdev.h" #include "hinic3_hwif.h" #include "hinic3_mbox.h"
@@ -616,6 +617,18 @@ static void write_mbox_msg_attr(struct hinic3_mbox *mbox, mbox_ctrl); } +static void hinic3_dump_mbox_reg (struct hinic3_hwdev *hwdev) +{ +u32 val; + + val =hinic3_hwif_read_reg (hwdev->hwif, +HINIC3_FUNC_CSR_MAILBOX_CONTROL_OFF ); +dev_err (hwdev->dev,"Mailbox control reg: 0x%x\n" , val); + val =hinic3_hwif_read_reg (hwdev->hwif, +HINIC3_FUNC_CSR_MAILBOX_INT_OFF ); +dev_err (hwdev->dev,"Mailbox interrupt offset: 0x%x\n" , val); +} +static u16 get_mbox_status (const struct hinic3_send_mbox *mbox) {__be64 *wb_status = mbox->wb_vaddr;
@@ -670,6 +683,7 @@ static int send_mbox_seg(struct hinic3_mbox *mbox, __le64 header,if (err) {dev_err (hwdev->dev,"Send mailbox segment timeout, wb status: 0x%x\n" , wb_status); +hinic3_dump_mbox_reg (hwdev);return err; }
@@ -825,6 +839,7 @@ int hinic3_send_mbox_to_mgmt(struct hinic3_hwdev *hwdev, u8 mod, u16 cmd,if (wait_mbox_msg_completion (mbox, msg_params->timeout_ms)) {dev_err (hwdev->dev,"Send mbox msg timeout, msg_id: %u\n" , msg_info.msg_id); +hinic3_dump_aeq_info (mbox->hwdev); err = -ETIMEDOUT ; goto err_send; }
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 3/15 hinic3: Add chip_present_flag checks to prevent errors when card is absent
In reply to Fan Gong--- drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c | 10 +++++++++- .../net/ethernet/huawei/hinic3/hinic3_common.h | 1 + .../net/ethernet/huawei/hinic3/hinic3_hw_comm.c | 7 +++++++ .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 5 +++++ .../net/ethernet/huawei/hinic3/hinic3_hwdev.h | 1 + drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c | 10 +++++++--- drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c | 12 ++++++++++++ .../ethernet/huawei/hinic3/hinic3_netdev_ops.c | 16 ++++++++++------ 8 files changed, 52 insertions(+), 10 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c +9 -1
@@ -353,7 +353,8 @@ static int wait_cmdqs_enable(struct hinic3_cmdqs *cmdqs)if (cmdqs->status &HINIC3_CMDQ_ENABLE )return 0 ;usleep_range (1000 ,2000 ); - }while (time_before (jiffies, end) && !cmdqs->disable_flag); + }while (time_before (jiffies, end) && !cmdqs->disable_flag && + cmdqs->hwdev->chip_present_flag); cmdqs->disable_flag =1 ;
@@ -733,6 +734,10 @@ int hinic3_cmdq_direct_resp(struct hinic3_hwdev *hwdev, u8 mod, u8 cmd, {struct hinic3_cmdqs *cmdqs;int err; + +if (!hwdev->chip_present_flag) +return -ETIMEDOUT ; + err =cmdq_params_valid (hwdev, buf_in);if (err) {dev_err (hwdev->dev,"Invalid CMDQ parameters\n" );
@@ -762,6 +767,9 @@ int hinic3_cmdq_detail_resp(struct hinic3_hwdev *hwdev, u8 mod, u8 cmd,struct hinic3_cmdqs *cmdqs;int err; +if (!hwdev->chip_present_flag) +return -ETIMEDOUT ; + err =cmdq_params_valid (hwdev, buf_in);if (err) goto err_out;
drivers/net/ethernet/huawei/hinic3/hinic3_common.h +1 -0
@@ -21,6 +21,7 @@ struct hinic3_dma_addr_align {enum hinic3_wait_return {HINIC3_WAIT_PROCESS_CPL =0 ,HINIC3_WAIT_PROCESS_WAITING =1 , +HINIC3_WAIT_PROCESS_ERR =2 , };struct hinic3_sge {
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c +7 -0
@@ -300,6 +300,10 @@ static enum hinic3_wait_return check_cmdq_stop_handler(void *priv_data)enum hinic3_cmdq_type cmdq_type;struct hinic3_cmdqs *cmdqs; +/* Stop waiting when card unpresent */ +if (!hwdev->chip_present_flag) +return HINIC3_WAIT_PROCESS_CPL ; + cmdqs = hwdev->cmdqs;for (cmdq_type =0 ; cmdq_type < cmdqs->cmdq_num; cmdq_type++) {if (!hinic3_cmdq_idle (&cmdqs->cmdq[cmdq_type]))
@@ -347,6 +351,9 @@ int hinic3_func_rx_tx_flush(struct hinic3_hwdev *hwdev)int ret =0 ;int err; +if (!hwdev->chip_present_flag) +return 0 ; + err =wait_cmdq_stop (hwdev);if (err) {dev_warn (hwdev->dev,"CMDQ is still working, CMDQ timeout value is unreasonable\n" );
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c +5 -0
@@ -32,6 +32,9 @@#define HINIC3_PCIE_PH_DISABLE 0#define HINIC3_PCIE_MSIX_ATTR_ENTRY 0 +#define HINIC3_CHIP_PRESENT 1 +#define HINIC3_CHIP_ABSENT 0 +#define HINIC3_DEFAULT_EQ_MSIX_PENDING_LIMIT 0#define HINIC3_DEFAULT_EQ_MSIX_COALESC_TIMER_CFG 0xFF#define HINIC3_DEFAULT_EQ_MSIX_RESEND_TIMER_CFG 7
@@ -545,6 +548,7 @@ int hinic3_init_hwdev(struct pci_dev *pdev)dev_err (hwdev->dev,"Failed to init hwif\n" ); goto err_free_hwdev; } + hwdev->chip_present_flag =HINIC3_CHIP_PRESENT ; hwdev->workq =alloc_workqueue (HINIC3_HWDEV_WQ_NAME ,WQ_MEM_RECLAIM |WQ_PERCPU ,HINIC3_WQ_MAX_REQ );
@@ -621,6 +625,7 @@ void hinic3_set_api_stop(struct hinic3_hwdev *hwdev)struct hinic3_recv_msg *recv_resp_msg;struct hinic3_mbox *mbox; + hwdev->chip_present_flag =HINIC3_CHIP_ABSENT ;spin_lock_bh (&hwdev->channel_lock);if (HINIC3_IS_PF (hwdev) &&test_bit (HINIC3_HWDEV_MGMT_INITED , &hwdev->func_state)) {
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.h +1 -0
@@ -76,6 +76,7 @@ struct hinic3_hwdev {u32 wq_page_size;u8 max_cmdq;ulong func_state; +int chip_present_flag; };struct hinic3_event_info {
drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c +7 -3
@@ -94,12 +94,16 @@ void hinic3_hwif_write_reg(struct hinic3_hwif *hwif, u32 reg, u32 val)static enum hinic3_wait_return check_hwif_ready_handler (void *priv_data) {struct hinic3_hwdev *hwdev = priv_data; -u32 attr1; +u32 attr1, status; attr1 =hinic3_hwif_read_reg (hwdev->hwif,HINIC3_CSR_FUNC_ATTR1_ADDR ); + status = !HINIC3_AF1_GET (attr1,MGMT_INIT_STATUS ); +if (status ==HINIC3_PCIE_LINK_DOWN ) +return HINIC3_WAIT_PROCESS_ERR ; +else if (!status) +return HINIC3_WAIT_PROCESS_CPL ; -return HINIC3_AF1_GET (attr1,MGMT_INIT_STATUS ) ? -HINIC3_WAIT_PROCESS_CPL :HINIC3_WAIT_PROCESS_WAITING ; +return HINIC3_WAIT_PROCESS_WAITING ; }static int wait_hwif_ready (struct hinic3_hwdev *hwdev)
drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c +12 -0
@@ -646,6 +646,9 @@ static enum hinic3_wait_return check_mbox_wb_status(void *priv_data)struct hinic3_mbox *mbox = priv_data;u16 wb_status; +if (!mbox->hwdev->chip_present_flag) +return HINIC3_WAIT_PROCESS_ERR ; + wb_status =get_mbox_status (&mbox->send_mbox); return MBOX_STATUS_FINISHED(wb_status) ?
@@ -788,6 +791,9 @@ static enum hinic3_wait_return check_mbox_msg_finish(void *priv_data) {struct hinic3_mbox *mbox = priv_data; +if (!mbox->hwdev->chip_present_flag) +return HINIC3_WAIT_PROCESS_ERR ; +return (mbox->event_flag ==MBOX_EVENT_SUCCESS ) ?HINIC3_WAIT_PROCESS_CPL :HINIC3_WAIT_PROCESS_WAITING ; }
@@ -819,6 +825,9 @@ int hinic3_send_mbox_to_mgmt(struct hinic3_hwdev *hwdev, u8 mod, u16 cmd,u32 msg_len;int err; +if (!hwdev->chip_present_flag) +return -EPERM ; +/* expect response message */ msg_desc =get_mbox_msg_desc (mbox,MBOX_MSG_RESP ,MBOX_MGMT_FUNC_ID );mutex_lock (&mbox->mbox_send_lock);
@@ -897,6 +906,9 @@ int hinic3_send_mbox_to_mgmt_no_ack(struct hinic3_hwdev *hwdev, u8 mod, u16 cmd,struct mbox_msg_info msg_info = {};int err; +if (!hwdev->chip_present_flag) +return -EPERM ; +mutex_lock (&mbox->mbox_send_lock); err = send_mbox_msg(mbox, mod, cmd, msg_params->buf_in, msg_params->in_size, MBOX_MGMT_FUNC_ID,
drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c +10 -6
@@ -417,13 +417,17 @@ static void hinic3_vport_down(struct net_device *netdev)netif_carrier_off (netdev);netif_tx_disable (netdev); - glb_func_id =hinic3_global_func_id (nic_dev->hwdev); -hinic3_set_vport_enable (nic_dev->hwdev, glb_func_id, false); +if (nic_dev->hwdev->chip_present_flag) { +hinic3_maybe_set_port_state (netdev, false); -hinic3_flush_txqs (netdev); -/* wait to guarantee that no packets will be sent to host */ -msleep (100 ); -hinic3_flush_qps_res (nic_dev->hwdev); + glb_func_id =hinic3_global_func_id (nic_dev->hwdev); +hinic3_set_vport_enable (nic_dev->hwdev, glb_func_id, false); + +hinic3_flush_txqs (netdev); +/* wait to guarantee that no packets will be sent to host */ +msleep (100 ); +hinic3_flush_qps_res (nic_dev->hwdev); + } }static int hinic3_open (struct net_device *netdev)
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 4/15 hinic3: Add RX GRO and VLAN offload support
In reply to Fan Gong--- .../net/ethernet/huawei/hinic3/hinic3_rx.c | 26 +++++++++++++++++++ .../net/ethernet/huawei/hinic3/hinic3_rx.h | 3 +++ 2 files changed, 29 insertions(+)
drivers/net/ethernet/huawei/hinic3/hinic3_rx.c +26 -0
@@ -357,6 +357,23 @@ static void hinic3_rx_csum(struct hinic3_rxq *rxq, u32 offload_type, } } +static void hinic3_rx_gro (struct hinic3_rxq *rxq,u32 offload_type, +struct sk_buff *skb) +{ +struct net_device *netdev = rxq->netdev; +bool l2_tunnel; + +if (!(netdev->features &NETIF_F_GRO )) +return ; + + l2_tunnel =HINIC3_GET_RX_TUNNEL_PKT_FORMAT (offload_type) == +HINIC3_RX_PKT_FORMAT_VXLAN ?1 :0 ; +if (l2_tunnel && skb->ip_summed ==CHECKSUM_UNNECESSARY ) { +/* If we checked the outer header let the stack know */ + skb->csum_level =1 ; + } +} +static void hinic3_lro_set_gso_params (struct sk_buff *skb,u16 num_lro) {struct ethhdr *eth = (struct ethhdr *)(skb->data);
@@ -389,6 +406,15 @@ static int recv_one_pkt(struct hinic3_rxq *rxq, struct hinic3_rq_cqe *rx_cqe, offload_type =le32_to_cpu (rx_cqe->offload_type);hinic3_rx_csum (rxq, offload_type, status, skb); +hinic3_rx_gro (rxq, offload_type, skb); + +if ((netdev->features &NETIF_F_HW_VLAN_CTAG_RX ) && +RQ_CQE_OFFOLAD_TYPE_GET (offload_type,VLAN_EN )) { +u16 vid =RQ_CQE_SGE_GET (vlan_len,VLAN ); + +/* if the packet is a vlan pkt, the vid may be 0 */ +__vlan_hwaccel_put_tag (skb,htons (ETH_P_8021Q ), vid); + } num_lro =RQ_CQE_STATUS_GET (status,NUM_LRO );if (num_lro)
drivers/net/ethernet/huawei/hinic3/hinic3_rx.h +3 -0
@@ -15,6 +15,9 @@#define RQ_CQE_OFFOLAD_TYPE_GET (val, member) \ FIELD_GET(RQ_CQE_OFFOLAD_TYPE_##member##_MASK, val) +#define HINIC3_GET_RX_TUNNEL_PKT_FORMAT (offload_type) \ + RQ_CQE_OFFOLAD_TYPE_GET(offload_type, TUNNEL_PKT_FORMAT) +#define RQ_CQE_SGE_VLAN_MASK GENMASK(15, 0)#define RQ_CQE_SGE_LEN_MASK GENMASK(31, 16)#define RQ_CQE_SGE_GET (val, member) \
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 5/15 hinic3: Add msg_send_lock for message sending concurrecy
In reply to Fan Gong--- drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c | 5 +++++ drivers/net/ethernet/huawei/hinic3/hinic3_mbox.h | 2 ++ 2 files changed, 7 insertions(+)
drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c +5 -0
@@ -396,6 +396,7 @@ static int hinic3_mbox_pre_init(struct hinic3_hwdev *hwdev, { mbox->hwdev = hwdev;mutex_init (&mbox->mbox_send_lock); +mutex_init (&mbox->msg_send_lock);spin_lock_init (&mbox->mbox_lock); mbox->workq =create_singlethread_workqueue (HINIC3_MBOX_WQ_NAME );
@@ -723,6 +724,8 @@ static int send_mbox_msg(struct hinic3_mbox *mbox, u8 mod, u16 cmd,else rsp_aeq_id =0 ; +mutex_lock (&mbox->msg_send_lock); +if (dst_func ==MBOX_MGMT_FUNC_ID && !(hwdev->features[0 ] &MBOX_COMM_F_MBOX_SEGMENT )) { err = mbox_prepare_dma_msg(mbox, ack_type, &dma_msg,
@@ -776,6 +779,8 @@ static int send_mbox_msg(struct hinic3_mbox *mbox, u8 mod, u16 cmd, } err_send: +mutex_unlock (&mbox->msg_send_lock); +return err; }
drivers/net/ethernet/huawei/hinic3/hinic3_mbox.h +2 -0
@@ -114,6 +114,8 @@ struct hinic3_mbox {struct hinic3_hwdev *hwdev;/* lock for send mbox message and ack message */ struct mutex mbox_send_lock; +/* lock for send mbox message */ +struct mutex msg_send_lock;struct hinic3_send_mbox send_mbox;struct mbox_dma_queue sync_msg_queue;struct mbox_dma_queue async_msg_queue;
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 6/15 hinic3: Add PF device support and function type validation
In reply to Fan Gong--- .../net/ethernet/huawei/hinic3/hinic3_hwdev.c | 6 ++++++ .../net/ethernet/huawei/hinic3/hinic3_hwif.c | 21 +++++++++++++++++-- .../net/ethernet/huawei/hinic3/hinic3_lld.c | 1 + .../net/ethernet/huawei/hinic3/hinic3_mbox.c | 3 ++- .../huawei/hinic3/hinic3_pci_id_tbl.h | 1 + 5 files changed, 29 insertions(+), 3 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c +6 -0
@@ -423,6 +423,7 @@ static int init_cmdqs_channel(struct hinic3_hwdev *hwdev)return 0 ; err_reset_wq_page_size: +if (HINIC3_FUNC_TYPE (hwdev) !=HINIC3_FUNC_TYPE_VF )hinic3_set_wq_page_size (hwdev,hinic3_global_func_id (hwdev),HINIC3_MIN_PAGE_SIZE ); err_free_ceqs:
@@ -434,6 +435,11 @@ static int init_cmdqs_channel(struct hinic3_hwdev *hwdev)static void hinic3_free_cmdqs_channel (struct hinic3_hwdev *hwdev) {hinic3_comm_cmdqs_free (hwdev); + +if (HINIC3_FUNC_TYPE (hwdev) !=HINIC3_FUNC_TYPE_VF ) +hinic3_set_wq_page_size (hwdev,hinic3_global_func_id (hwdev), +HINIC3_MIN_PAGE_SIZE ); +hinic3_ceqs_free (hwdev); }
drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c +19 -2
@@ -70,11 +70,19 @@#define HINIC3_PPF_ELECTION_GET (val, member) \ FIELD_GET(HINIC3_PPF_ELECTION_##member##_MASK, val) +#define HINIC3_GET_REG_FLAG (reg) ((reg) & (~(HINIC3_REGS_FLAG_MASK)))#define HINIC3_GET_REG_ADDR (reg) ((reg) & (HINIC3_REGS_FLAG_MASK))static void __iomem *hinic3_reg_addr (struct hinic3_hwif *hwif,u32 reg) { -return hwif->cfg_regs_base +HINIC3_GET_REG_ADDR (reg); +void __iomem *addr; + +if (HINIC3_GET_REG_FLAG (reg) ==HINIC3_MGMT_REGS_FLAG ) + addr = hwif->mgmt_regs_base +HINIC3_GET_REG_ADDR (reg); +else + addr = hwif->cfg_regs_base +HINIC3_GET_REG_ADDR (reg); + +return addr; }u32 hinic3_hwif_read_reg (struct hinic3_hwif *hwif,u32 reg)
@@ -139,6 +147,7 @@ static void set_hwif_attr(struct hinic3_func_attr *attr, u32 attr0, u32 attr1,static int init_hwif_attr (struct hinic3_hwdev *hwdev) {u32 attr0, attr1, attr2, attr3, attr6; +struct hinic3_func_attr *attr;struct hinic3_hwif *hwif; hwif = hwdev->hwif;
@@ -162,7 +171,15 @@ static int init_hwif_attr(struct hinic3_hwdev *hwdev)if (attr6 ==HINIC3_PCIE_LINK_DOWN )return -EFAULT ; -set_hwif_attr (&hwif->attr, attr0, attr1, attr2, attr3, attr6); + attr = &hwif->attr; +set_hwif_attr (attr, attr0, attr1, attr2, attr3, attr6); + +if (attr->func_type !=HINIC3_FUNC_TYPE_VF && + attr->func_type !=HINIC3_FUNC_TYPE_PF ) { +dev_err (hwdev->dev,"unexpected func_type %u\n" , + attr->func_type); +return -EINVAL ; + }if (!hwif->attr.num_ceqs) {dev_err (hwdev->dev,"Ceq num cfg in fw is zero\n" );
drivers/net/ethernet/huawei/hinic3/hinic3_lld.c +1 -0
@@ -426,6 +426,7 @@ static void hinic3_remove(struct pci_dev *pdev) }static const struct pci_device_id hinic3_pci_table[] = { + {PCI_VDEVICE (HUAWEI ,PCI_DEV_ID_HINIC3_PF ),0 }, {PCI_VDEVICE (HUAWEI ,PCI_DEV_ID_HINIC3_VF ),0 }, {0 ,0 }
drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c +2 -1
@@ -462,7 +462,8 @@ void hinic3_free_mbox(struct hinic3_hwdev *hwdev)destroy_workqueue (mbox->workq);free_mbox_wb_status (mbox); -hinic3_uninit_func_mbox_msg_channel (hwdev); +if (HINIC3_IS_VF (hwdev)) +hinic3_uninit_func_mbox_msg_channel (hwdev);uninit_mgmt_msg_channel (mbox);kfree (mbox); }
drivers/net/ethernet/huawei/hinic3/hinic3_pci_id_tbl.h +1 -0
@@ -4,6 +4,7 @@#ifndef _HINIC3_PCI_ID_TBL_H_#define _HINIC3_PCI_ID_TBL_H_ +#define PCI_DEV_ID_HINIC3_PF 0x0222#define PCI_DEV_ID_HINIC3_VF 0x375F#endif
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 7/15 hinic3: Add PF FLR wait and timeout handling
In reply to Fan GongAdd a mechanisim for PF to wait for FLR completion, ensuring HW state consistency after a FLR event.
--- .../ethernet/huawei/hinic3/hinic3_hw_comm.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c +30 -0
@@ -292,6 +292,28 @@ int hinic3_set_cmdq_depth(struct hinic3_hwdev *hwdev, u16 cmdq_depth)return 0 ; } +#define HINIC3_FLR_TIMEOUT 1000 + +static enum hinic3_wait_return hinic3_check_flr_finish_handler (void *priv_data) +{ +struct hinic3_hwif *hwif = priv_data; +enum hinic3_pf_status status; + + status =hinic3_get_pf_status (hwif); +if (status ==HINIC3_PF_STATUS_FLR_FINISH_FLAG ) { +hinic3_set_pf_status (hwif,HINIC3_PF_STATUS_ACTIVE_FLAG ); +return HINIC3_WAIT_PROCESS_CPL ; + } + +return HINIC3_WAIT_PROCESS_WAITING ; +} + +static int hinic3_wait_for_flr_finish (struct hinic3_hwif *hwif) +{ +return hinic3_wait_for_timeout (hwif, hinic3_check_flr_finish_handler, +HINIC3_FLR_TIMEOUT ,0xa *USEC_PER_MSEC ); +} +#define HINIC3_WAIT_CMDQ_IDLE_TIMEOUT 5000static enum hinic3_wait_return check_cmdq_stop_handler (void *priv_data)
@@ -389,6 +411,14 @@ int hinic3_func_rx_tx_flush(struct hinic3_hwdev *hwdev) ret = err; } +if (HINIC3_FUNC_TYPE (hwdev) !=HINIC3_FUNC_TYPE_VF ) { + err =hinic3_wait_for_flr_finish (hwif); +if (err) { +dev_warn (hwdev->dev,"Wait firmware FLR timeout\n" ); + ret = err; + } + } +hinic3_toggle_doorbell (hwif,ENABLE_DOORBELL ); err =hinic3_reinit_cmdq_ctxts (hwdev);
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 8/15 hinic3: Add PF/VF capability parsing and parameter validation
In reply to Fan Gong--- .../ethernet/huawei/hinic3/hinic3_hw_cfg.c | 53 ++++++++++++++++++- .../ethernet/huawei/hinic3/hinic3_hw_cfg.h | 8 +++ 2 files changed, 60 insertions(+), 1 deletion(-)
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c +52 -1
@@ -17,6 +17,17 @@ static void hinic3_parse_pub_res_cap(struct hinic3_hwdev *hwdev, { cap->port_id = dev_cap->port_id; cap->supp_svcs_bitmap = dev_cap->svc_cap_en; + + cap->cos_valid_bitmap = dev_cap->valid_cos_bitmap; + cap->port_cos_valid_bitmap = dev_cap->port_cos_valid_bitmap; + +if (type !=HINIC3_FUNC_TYPE_VF ) + cap->max_vf = dev_cap->max_vf; +else + cap->max_vf =0 ; + +dev_dbg (hwdev->dev,"Port_id: 0x%x, cos_bitmap: 0x%x, Max_vf: 0x%x\n" , + cap->port_id, cap->cos_valid_bitmap, cap->max_vf); } static void hinic3_parse_l2nic_res_cap(struct hinic3_hwdev *hwdev,
@@ -28,6 +39,23 @@ static void hinic3_parse_l2nic_res_cap(struct hinic3_hwdev *hwdev, nic_svc_cap->max_sqs =min (dev_cap->nic_max_sq_id +1 ,HINIC3_CFG_MAX_QP ); + + nic_svc_cap->max_rqs = dev_cap->nic_max_rq_id +1 ; + nic_svc_cap->default_num_queues = dev_cap->nic_default_num_queues; + +dev_dbg (hwdev->dev,"L2nic resource capbility, max_sqs: 0x%x, max_rqs: 0x%x\n" , + nic_svc_cap->max_sqs, nic_svc_cap->max_rqs); + +/* Check parameters from firmware */ +if (nic_svc_cap->max_sqs >HINIC3_CFG_MAX_QP || + nic_svc_cap->max_rqs >HINIC3_CFG_MAX_QP ) { +dev_dbg (hwdev->dev, +"Number of qp exceeds limit[1-%d]: sq: %u, rq: %u\n" , +HINIC3_CFG_MAX_QP , nic_svc_cap->max_sqs, + nic_svc_cap->max_rqs); + nic_svc_cap->max_sqs =HINIC3_CFG_MAX_QP ; + nic_svc_cap->max_rqs =HINIC3_CFG_MAX_QP ; + } } static void hinic3_parse_dev_cap(struct hinic3_hwdev *hwdev,
@@ -69,6 +97,29 @@ static int get_cap_from_fw(struct hinic3_hwdev *hwdev,return 0 ; } +static int hinic3_get_dev_cap (struct hinic3_hwdev *hwdev) +{ +enum hinic3_func_type type =HINIC3_FUNC_TYPE (hwdev); +int err; + +switch (type) { +case HINIC3_FUNC_TYPE_PF : +case HINIC3_FUNC_TYPE_VF : + err =get_cap_from_fw (hwdev, type); +if (err) { +dev_err (hwdev->dev,"Failed to get PF capability\n" ); +return err; + } +break ; +default : +dev_err (hwdev->dev,"Unsupported PCI Function type: %d\n" , + type); +return -EINVAL ; + } + +return 0 ; +} +static int hinic3_init_irq_info (struct hinic3_hwdev *hwdev) {struct hinic3_cfg_mgmt_info *cfg_mgmt = hwdev->cfg_mgmt;
@@ -216,7 +267,7 @@ void hinic3_free_irq(struct hinic3_hwdev *hwdev, u32 irq_id)int hinic3_init_capability (struct hinic3_hwdev *hwdev) { -return get_cap_from_fw (hwdev,HINIC3_FUNC_TYPE_VF ); +return hinic3_get_dev_cap (hwdev); }bool hinic3_support_nic (struct hinic3_hwdev *hwdev)
drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.h +8 -0
@@ -26,6 +26,8 @@ struct hinic3_irq_info {struct hinic3_nic_service_cap {u16 max_sqs; +u16 max_rqs; +u16 default_num_queues; };/* Device capabilities */
@@ -34,6 +36,12 @@ struct hinic3_dev_cap {u16 supp_svcs_bitmap;/* Physical port */ u8 port_id; + +u8 cos_valid_bitmap; +u8 port_cos_valid_bitmap; +/* max number of VFs that PF supports */ +u16 max_vf; +struct hinic3_nic_service_cap nic_svc_cap; };
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 9/15 hinic3: Add ethtool basic ops
In reply to Fan Gong--- drivers/net/ethernet/huawei/hinic3/Makefile | 1 + .../ethernet/huawei/hinic3/hinic3_ethtool.c | 425 ++++++++++++++++++ .../ethernet/huawei/hinic3/hinic3_hw_comm.c | 28 ++ .../ethernet/huawei/hinic3/hinic3_hw_comm.h | 2 + .../ethernet/huawei/hinic3/hinic3_hw_intf.h | 12 + .../net/ethernet/huawei/hinic3/hinic3_main.c | 3 + .../huawei/hinic3/hinic3_mgmt_interface.h | 16 +- .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 90 ++++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 110 +++++ .../ethernet/huawei/hinic3/hinic3_nic_dev.h | 3 + .../net/ethernet/huawei/hinic3/hinic3_rss.c | 2 +- 11 files changed, 690 insertions(+), 2 deletions(-)
drivers/net/ethernet/huawei/hinic3/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_HINIC3) += hinic3.o hinic3-objs := hinic3_cmdq.o \ hinic3_common.o \ hinic3_eqs.o \ + hinic3_ethtool.o \ hinic3_filter.o \ hinic3_hw_cfg.o \ hinic3_hw_comm.o \
drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c new file +425 -0
425 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.c +28 -0
@@ -576,3 +576,31 @@ int hinic3_clean_root_ctxt(struct hinic3_hwdev *hwdev)return 0 ; } + +#define HINIC3_FW_VER_TYPE_MPU 1 + +int hinic3_get_mgmt_version (struct hinic3_hwdev *hwdev,u8 *mgmt_ver, +u8 version_size) +{ +struct comm_cmd_get_fw_version fw_ver = {}; +struct mgmt_msg_params msg_params = {}; +int err; + + fw_ver.fw_type =HINIC3_FW_VER_TYPE_MPU ; + +mgmt_msg_params_init_default (&msg_params, &fw_ver,sizeof (fw_ver)); + + err =hinic3_send_mbox_to_mgmt (hwdev,MGMT_MOD_COMM , +COMM_CMD_GET_FW_VERSION , &msg_params); + +if (err || fw_ver.head.status) { +dev_err (hwdev->dev, +"Failed to get fw version, err: %d, status: 0x%x\n" , + err, fw_ver.head.status); +return -EFAULT ; + } + +snprintf (mgmt_ver, version_size,"%s" , fw_ver.ver); + +return 0 ; +}
drivers/net/ethernet/huawei/hinic3/hinic3_hw_comm.h +2 -0
@@ -49,5 +49,7 @@ void hinic3_sync_time_to_fw(struct hinic3_hwdev *hwdev);int hinic3_set_root_ctxt (struct hinic3_hwdev *hwdev,u32 rq_depth,u32 sq_depth,int rx_buf_sz);int hinic3_clean_root_ctxt (struct hinic3_hwdev *hwdev); +int hinic3_get_mgmt_version (struct hinic3_hwdev *hwdev,u8 *mgmt_ver, +u8 version_size);#endif
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h +12 -0
@@ -114,6 +114,7 @@ enum comm_cmd {COMM_CMD_SET_DMA_ATTR =25 ,/* Commands for obtaining information */ +COMM_CMD_GET_FW_VERSION =60 ,COMM_CMD_SYNC_TIME =62 , COMM_CMD_SEND_BDF_INFO = 64, };
@@ -275,6 +276,17 @@ struct comm_cmd_bdf_info {u8 rsvd2[5 ]; }; +#define COMM_FW_VERSION_LEN 16 +#define COMM_FW_COMPILE_TIME_LEN 20 +struct comm_cmd_get_fw_version { +struct mgmt_msg_head head; + +u16 fw_type; +u16 rsvd1; +u8 ver[COMM_FW_VERSION_LEN ]; +u8 time[COMM_FW_COMPILE_TIME_LEN ]; +}; +/* Services supported by HW. HW uses these values when delivering events. * HW supports multiple services that are not yet supported by driver * (e.g. RoCE).
drivers/net/ethernet/huawei/hinic3/hinic3_main.c +3 -0
@@ -18,6 +18,7 @@#define HINIC3_NIC_DRV_DESC "Intelligent Network Interface Card Driver" +#define HINIC3_DEFAULT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_LINK)#define HINIC3_RX_BUF_LEN 2048#define HINIC3_LRO_REPLENISH_THLD 256#define HINIC3_NIC_DEV_WQ_NAME "hinic3_nic_dev_wq"
@@ -144,6 +145,7 @@ static int hinic3_init_nic_dev(struct net_device *netdev, nic_dev->hwdev = hwdev; nic_dev->pdev = pdev; + nic_dev->msg_enable =HINIC3_DEFAULT_MSG_ENABLE ; nic_dev->rx_buf_len =HINIC3_RX_BUF_LEN ; nic_dev->lro_replenish_thld =HINIC3_LRO_REPLENISH_THLD ; nic_dev->vlan_bitmap = kzalloc(HINIC3_VLAN_BITMAP_SIZE(nic_dev),
@@ -242,6 +244,7 @@ static void hinic3_sw_uninit(struct net_device *netdev)static void hinic3_assign_netdev_ops (struct net_device *netdev) {hinic3_set_netdev_ops (netdev); +hinic3_set_ethtool_ops (netdev); }static void netdev_feature_init (struct net_device *netdev)
drivers/net/ethernet/huawei/hinic3/hinic3_mgmt_interface.h +15 -1
@@ -183,7 +183,18 @@ struct l2nic_cmd_lro_timer {/* IEEE 802.1Qaz std */ #define L2NIC_DCB_COS_MAX 0x8 -struct l2nic_cmd_set_rss_ctx_tbl { +struct l2nic_cmd_pause_config { +struct mgmt_msg_head msg_head; +u8 port_id; +u8 opcode; +u16 rsvd1; +u8 auto_neg; +u8 rx_pause; +u8 tx_pause; +u8 rsvd2[5 ]; +}; + +struct l2nic_cmd_rss_ctx_tbl {struct mgmt_msg_head msg_head;u16 func_id;u16 rsvd1;
@@ -238,6 +249,7 @@ enum l2nic_cmd {L2NIC_CMD_CFG_RSS_HASH_KEY =63 ,L2NIC_CMD_CFG_RSS_HASH_ENGINE =64 ,L2NIC_CMD_SET_RSS_CTX_TBL =65 , +L2NIC_CMD_CFG_PAUSE_INFO =101 ,L2NIC_CMD_QOS_DCB_STATE =110 ,L2NIC_CMD_FORCE_PKT_DROP =113 , L2NIC_CMD_MAX = 256,
@@ -259,6 +271,8 @@ enum l2nic_ucode_cmd {enum mag_cmd {MAG_CMD_SET_PORT_ENABLE =6 ,MAG_CMD_GET_LINK_STATUS =7 , + +MAG_CMD_GET_PORT_INFO =153 , };/* firmware also use this cmd report link event to driver */
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c +90 -0
99 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.h +110 -0
143 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_dev.h +3 -0
@@ -101,6 +101,7 @@ struct hinic3_nic_dev {struct hinic3_hwdev *hwdev;struct hinic3_nic_io *nic_io; +u32 msg_enable;u16 max_qps;u16 rx_buf_len;u32 lro_replenish_thld;
@@ -148,4 +149,6 @@ void hinic3_qps_irq_uninit(struct net_device *netdev);void hinic3_set_rx_mode_work (struct work_struct *work);void hinic3_clean_mac_list_filter (struct net_device *netdev); +void hinic3_set_ethtool_ops (struct net_device *netdev); +#endif
drivers/net/ethernet/huawei/hinic3/hinic3_rss.c +1 -1
@@ -132,7 +132,7 @@ static int hinic3_rss_set_indir_tbl(struct hinic3_hwdev *hwdev,static int hinic3_set_rss_type (struct hinic3_hwdev *hwdev,struct hinic3_rss_type rss_type) { -struct l2nic_cmd_set_rss_ctx_tbl ctx_tbl = {}; +struct l2nic_cmd_rss_ctx_tbl ctx_tbl = {};struct mgmt_msg_params msg_params = {};u32 ctx;int err;
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 10/15 hinic3: Add ethtool queue ops
In reply to Fan Gong--- .../ethernet/huawei/hinic3/hinic3_ethtool.c | 94 +++++++++++++++++++ .../net/ethernet/huawei/hinic3/hinic3_irq.c | 3 +- .../net/ethernet/huawei/hinic3/hinic3_main.c | 3 + .../huawei/hinic3/hinic3_netdev_ops.c | 60 ++++++++++++ .../ethernet/huawei/hinic3/hinic3_nic_dev.h | 12 +++ .../ethernet/huawei/hinic3/hinic3_nic_io.h | 4 + 6 files changed, 175 insertions(+), 1 deletion(-)
drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c +94 -0
@@ -409,6 +409,98 @@ hinic3_get_link_ksettings(struct net_device *netdev,return 0 ; } +static void hinic3_get_ringparam (struct net_device *netdev, +struct ethtool_ringparam *ring, +struct kernel_ethtool_ringparam *kernel_ring, +struct netlink_ext_ack *extack) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); + + ring->rx_max_pending =HINIC3_MAX_RX_QUEUE_DEPTH ; + ring->tx_max_pending =HINIC3_MAX_TX_QUEUE_DEPTH ; + ring->rx_pending = nic_dev->rxqs[0 ].q_depth; + ring->tx_pending = nic_dev->txqs[0 ].q_depth; +} + +static void hinic3_update_qp_depth (struct net_device *netdev, +u32 sq_depth,u32 rq_depth) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +u16 i; + + nic_dev->q_params.sq_depth = sq_depth; + nic_dev->q_params.rq_depth = rq_depth; +for (i =0 ; i < nic_dev->max_qps; i++) { + nic_dev->txqs[i].q_depth = sq_depth; + nic_dev->txqs[i].q_mask = sq_depth -1 ; + nic_dev->rxqs[i].q_depth = rq_depth; + nic_dev->rxqs[i].q_mask = rq_depth -1 ; + } +} + +static int hinic3_check_ringparam_valid (struct net_device *netdev, +const struct ethtool_ringparam *ring) +{ +if (ring->rx_jumbo_pending || ring->rx_mini_pending) { +netdev_err (netdev,"Unsupported rx_jumbo_pending/rx_mini_pending\n" ); +return -EINVAL ; + } + +if (ring->tx_pending >HINIC3_MAX_TX_QUEUE_DEPTH || + ring->tx_pending <HINIC3_MIN_QUEUE_DEPTH || + ring->rx_pending >HINIC3_MAX_RX_QUEUE_DEPTH || + ring->rx_pending <HINIC3_MIN_QUEUE_DEPTH ) { +netdev_err (netdev, +"Queue depth out of rang tx[%d-%d] rx[%d-%d]\n" , +HINIC3_MIN_QUEUE_DEPTH ,HINIC3_MAX_TX_QUEUE_DEPTH , +HINIC3_MIN_QUEUE_DEPTH ,HINIC3_MAX_RX_QUEUE_DEPTH ); +return -EINVAL ; + } + +return 0 ; +} + +static int hinic3_set_ringparam (struct net_device *netdev, +struct ethtool_ringparam *ring, +struct kernel_ethtool_ringparam *kernel_ring, +struct netlink_ext_ack *extack) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +struct hinic3_dyna_txrxq_params q_params = {}; +u32 new_sq_depth, new_rq_depth; +int err; + + err =hinic3_check_ringparam_valid (netdev, ring); +if (err) +return err; + + new_sq_depth =1U <<ilog2 (ring->tx_pending); + new_rq_depth =1U <<ilog2 (ring->rx_pending); +if (new_sq_depth == nic_dev->q_params.sq_depth && + new_rq_depth == nic_dev->q_params.rq_depth) +return 0 ; + +netdev_dbg (netdev,"Change Tx/Rx ring depth from %u/%u to %u/%u\n" , + nic_dev->q_params.sq_depth, nic_dev->q_params.rq_depth, + new_sq_depth, new_rq_depth); + +if (!netif_running (netdev)) { +hinic3_update_qp_depth (netdev, new_sq_depth, new_rq_depth); + }else { + q_params = nic_dev->q_params; + q_params.sq_depth = new_sq_depth; + q_params.rq_depth = new_rq_depth; + + err =hinic3_change_channel_settings (netdev, &q_params); +if (err) { +netdev_err (netdev,"Failed to change channel settings\n" ); +return err; + } + } + +return 0 ; +} +static const struct ethtool_ops hinic3_ethtool_ops = { .supported_coalesce_params =ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_PKT_RATE_RX_USECS ,
@@ -417,6 +509,8 @@ static const struct ethtool_ops hinic3_ethtool_ops = { .get_msglevel = hinic3_get_msglevel, .set_msglevel = hinic3_set_msglevel, .get_link = ethtool_op_get_link, + .get_ringparam = hinic3_get_ringparam, + .set_ringparam = hinic3_set_ringparam, };void hinic3_set_ethtool_ops (struct net_device *netdev)
drivers/net/ethernet/huawei/hinic3/hinic3_irq.c +2 -1
@@ -137,7 +137,8 @@ static int hinic3_set_interrupt_moder(struct net_device *netdev, u16 q_id,struct hinic3_interrupt_info info = {};int err; -if (q_id >= nic_dev->q_params.num_qps) +if (!HINIC3_CHANNEL_RES_VALID (nic_dev) || + q_id >= nic_dev->q_params.num_qps)return 0 ; info.interrupt_coalesc_set =1 ;
drivers/net/ethernet/huawei/hinic3/hinic3_main.c +3 -0
@@ -316,6 +316,9 @@ static void hinic3_link_status_change(struct net_device *netdev, {struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +if (!HINIC3_CHANNEL_RES_VALID (nic_dev)) +return ; +if (link_status_up) {if (netif_carrier_ok (netdev))return ;
drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c +60 -0
77 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_dev.h +12 -0
@@ -10,6 +10,9 @@#include "hinic3_hw_cfg.h" #include "hinic3_hwdev.h" #include "hinic3_mgmt_interface.h" +#include "hinic3_nic_io.h" +#include "hinic3_tx.h" +#include "hinic3_rx.h" #define HINIC3_VLAN_BITMAP_BYTE_SIZE (nic_dev) (sizeof(*(nic_dev)->vlan_bitmap))#define HINIC3_VLAN_BITMAP_SIZE (nic_dev) \
@@ -20,8 +23,13 @@ enum hinic3_flags {HINIC3_MAC_FILTER_CHANGED ,HINIC3_RSS_ENABLE ,HINIC3_UPDATE_MAC_FILTER , + HINIC3_CHANGE_RES_INVALID, }; +#define HINIC3_CHANNEL_RES_VALID (nic_dev) \ + (test_bit(HINIC3_INTF_UP, &(nic_dev)->flags) && \ + !test_bit(HINIC3_CHANGE_RES_INVALID, &(nic_dev)->flags)) +enum hinic3_event_work_flags {HINIC3_EVENT_WORK_TX_TIMEOUT , };
@@ -143,6 +151,10 @@ struct hinic3_nic_dev {void hinic3_set_netdev_ops (struct net_device *netdev);int hinic3_set_hw_features (struct net_device *netdev); +int +hinic3_change_channel_settings (struct net_device *netdev, +struct hinic3_dyna_txrxq_params *trxq_params); +int hinic3_qps_irq_init (struct net_device *netdev);void hinic3_qps_irq_uninit (struct net_device *netdev);
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.h +4 -0
@@ -14,6 +14,10 @@ struct hinic3_nic_dev;#define HINIC3_RQ_WQEBB_SHIFT 3#define HINIC3_SQ_WQEBB_SIZE BIT(HINIC3_SQ_WQEBB_SHIFT) +#define HINIC3_MAX_TX_QUEUE_DEPTH 65536 +#define HINIC3_MAX_RX_QUEUE_DEPTH 16384 +#define HINIC3_MIN_QUEUE_DEPTH 128 +/* ******************** RQ_CTRL ******************** */ enum hinic3_rq_wqe_type {HINIC3_NORMAL_RQ_WQE =1 ,
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 11/15 hinic3: Add ethtool statistic ops
In reply to Fan Gong--- .../ethernet/huawei/hinic3/hinic3_ethtool.c | 414 ++++++++++++++++++ .../ethernet/huawei/hinic3/hinic3_hw_intf.h | 13 +- .../huawei/hinic3/hinic3_mgmt_interface.h | 37 ++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 64 +++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 109 +++++ .../ethernet/huawei/hinic3/hinic3_nic_dev.h | 15 + .../net/ethernet/huawei/hinic3/hinic3_rx.c | 58 ++- .../net/ethernet/huawei/hinic3/hinic3_rx.h | 14 + .../net/ethernet/huawei/hinic3/hinic3_tx.c | 72 ++- .../net/ethernet/huawei/hinic3/hinic3_tx.h | 2 + 10 files changed, 789 insertions(+), 9 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c +414 -0
@@ -501,6 +501,417 @@ static int hinic3_set_ringparam(struct net_device *netdev,return 0 ; } +struct hinic3_stats { +char name[ETH_GSTRING_LEN ]; +u32 size; +int offset; +}; + +#define HINIC3_NETDEV_STAT (_stat_item) { \ + .name = #_stat_item, \ + .size = sizeof_field(struct rtnl_link_stats64, _stat_item), \ + .offset = offsetof(struct rtnl_link_stats64, _stat_item) \ +} + +static const struct hinic3_stats hinic3_netdev_stats[] = { +HINIC3_NETDEV_STAT (rx_packets), +HINIC3_NETDEV_STAT (tx_packets), +HINIC3_NETDEV_STAT (rx_bytes), +HINIC3_NETDEV_STAT (tx_bytes), +HINIC3_NETDEV_STAT (rx_errors), +HINIC3_NETDEV_STAT (tx_errors), +HINIC3_NETDEV_STAT (rx_dropped), +HINIC3_NETDEV_STAT (tx_dropped), +HINIC3_NETDEV_STAT (multicast), +HINIC3_NETDEV_STAT (collisions), +HINIC3_NETDEV_STAT (rx_length_errors), +HINIC3_NETDEV_STAT (rx_over_errors), +HINIC3_NETDEV_STAT (rx_crc_errors), +HINIC3_NETDEV_STAT (rx_frame_errors), +HINIC3_NETDEV_STAT (rx_fifo_errors), +HINIC3_NETDEV_STAT (rx_missed_errors), +HINIC3_NETDEV_STAT (tx_aborted_errors), +HINIC3_NETDEV_STAT (tx_carrier_errors), +HINIC3_NETDEV_STAT (tx_fifo_errors), +HINIC3_NETDEV_STAT (tx_heartbeat_errors), +}; + +#define HINIC3_NIC_STAT (_stat_item) { \ + .name = #_stat_item, \ + .size = sizeof_field(struct hinic3_nic_stats, _stat_item), \ + .offset = offsetof(struct hinic3_nic_stats, _stat_item) \ +} + +#define HINIC3_RXQ_STAT (_stat_item) { \ + .name = "rxq%d_"#_stat_item, \ + .size = sizeof_field(struct hinic3_rxq_stats, _stat_item), \ + .offset = offsetof(struct hinic3_rxq_stats, _stat_item) \ +} + +#define HINIC3_TXQ_STAT (_stat_item) { \ + .name = "txq%d_"#_stat_item, \ + .size = sizeof_field(struct hinic3_txq_stats, _stat_item), \ + .offset = offsetof(struct hinic3_txq_stats, _stat_item) \ +} + +static struct hinic3_stats hinic3_rx_queue_stats[] = { +HINIC3_RXQ_STAT (packets), +HINIC3_RXQ_STAT (bytes), +HINIC3_RXQ_STAT (errors), +HINIC3_RXQ_STAT (csum_errors), +HINIC3_RXQ_STAT (other_errors), +HINIC3_RXQ_STAT (dropped), +HINIC3_RXQ_STAT (rx_buf_empty), +HINIC3_RXQ_STAT (alloc_skb_err), +HINIC3_RXQ_STAT (alloc_rx_buf_err), +HINIC3_RXQ_STAT (restore_drop_sge), +}; + +static struct hinic3_stats hinic3_tx_queue_stats[] = { +HINIC3_TXQ_STAT (packets), +HINIC3_TXQ_STAT (bytes), +HINIC3_TXQ_STAT (busy), +HINIC3_TXQ_STAT (dropped), +HINIC3_TXQ_STAT (skb_pad_err), +HINIC3_TXQ_STAT (frag_len_overflow), +HINIC3_TXQ_STAT (offload_cow_skb_err), +HINIC3_TXQ_STAT (map_frag_err), +HINIC3_TXQ_STAT (unknown_tunnel_pkt), +HINIC3_TXQ_STAT (frag_size_err), +}; + +#define HINIC3_FUNC_STAT (_stat_item) { \ + .name = #_stat_item, \ + .size = sizeof_field(struct l2nic_vport_stats, _stat_item), \ + .offset = offsetof(struct l2nic_vport_stats, _stat_item) \ +} + +static struct hinic3_stats hinic3_function_stats[] = { +HINIC3_FUNC_STAT (tx_unicast_pkts_vport), +HINIC3_FUNC_STAT (tx_unicast_bytes_vport), +HINIC3_FUNC_STAT (tx_multicast_pkts_vport), +HINIC3_FUNC_STAT (tx_multicast_bytes_vport), +HINIC3_FUNC_STAT (tx_broadcast_pkts_vport), +HINIC3_FUNC_STAT (tx_broadcast_bytes_vport), + +HINIC3_FUNC_STAT (rx_unicast_pkts_vport), +HINIC3_FUNC_STAT (rx_unicast_bytes_vport), +HINIC3_FUNC_STAT (rx_multicast_pkts_vport), +HINIC3_FUNC_STAT (rx_multicast_bytes_vport), +HINIC3_FUNC_STAT (rx_broadcast_pkts_vport), +HINIC3_FUNC_STAT (rx_broadcast_bytes_vport), + +HINIC3_FUNC_STAT (tx_discard_vport), +HINIC3_FUNC_STAT (rx_discard_vport), +HINIC3_FUNC_STAT (tx_err_vport), +HINIC3_FUNC_STAT (rx_err_vport), +}; + +#define HINIC3_PORT_STAT (_stat_item) { \ + .name = #_stat_item, \ + .size = sizeof_field(struct mag_cmd_port_stats, _stat_item), \ + .offset = offsetof(struct mag_cmd_port_stats, _stat_item) \ +} + +static struct hinic3_stats hinic3_port_stats[] = { +HINIC3_PORT_STAT (mac_tx_fragment_pkt_num), +HINIC3_PORT_STAT (mac_tx_undersize_pkt_num), +HINIC3_PORT_STAT (mac_tx_undermin_pkt_num), +HINIC3_PORT_STAT (mac_tx_64_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_65_127_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_128_255_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_256_511_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_512_1023_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_1024_1518_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_1519_2047_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_2048_4095_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_4096_8191_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_8192_9216_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_9217_12287_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_12288_16383_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_1519_max_bad_pkt_num), +HINIC3_PORT_STAT (mac_tx_1519_max_good_pkt_num), +HINIC3_PORT_STAT (mac_tx_oversize_pkt_num), +HINIC3_PORT_STAT (mac_tx_jabber_pkt_num), +HINIC3_PORT_STAT (mac_tx_bad_pkt_num), +HINIC3_PORT_STAT (mac_tx_bad_oct_num), +HINIC3_PORT_STAT (mac_tx_good_pkt_num), +HINIC3_PORT_STAT (mac_tx_good_oct_num), +HINIC3_PORT_STAT (mac_tx_total_pkt_num), +HINIC3_PORT_STAT (mac_tx_total_oct_num), +HINIC3_PORT_STAT (mac_tx_uni_pkt_num), +HINIC3_PORT_STAT (mac_tx_multi_pkt_num), +HINIC3_PORT_STAT (mac_tx_broad_pkt_num), +HINIC3_PORT_STAT (mac_tx_pause_num), +HINIC3_PORT_STAT (mac_tx_pfc_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri0_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri1_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri2_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri3_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri4_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri5_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri6_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri7_pkt_num), +HINIC3_PORT_STAT (mac_tx_control_pkt_num), +HINIC3_PORT_STAT (mac_tx_err_all_pkt_num), +HINIC3_PORT_STAT (mac_tx_from_app_good_pkt_num), +HINIC3_PORT_STAT (mac_tx_from_app_bad_pkt_num), + +HINIC3_PORT_STAT (mac_rx_fragment_pkt_num), +HINIC3_PORT_STAT (mac_rx_undersize_pkt_num), +HINIC3_PORT_STAT (mac_rx_undermin_pkt_num), +HINIC3_PORT_STAT (mac_rx_64_oct_pkt_num), +HINIC3_PORT_STAT (mac_rx_65_127_oct_pkt_num), +HINIC3_PORT_STAT (mac_rx_128_255_oct_pkt_num), +HINIC3_PORT_STAT (mac_rx_256_511_oct_pkt_num), +HINIC3_PORT_STAT (mac_rx_512_1023_oct_pkt_num), +HINIC3_PORT_STAT (mac_rx_1024_1518_oct_pkt_num), +HINIC3_PORT_STAT (mac_rx_1519_2047_oct_pkt_num), +HINIC3_PORT_STAT (mac_rx_2048_4095_oct_pkt_num), +HINIC3_PORT_STAT (mac_rx_4096_8191_oct_pkt_num), +HINIC3_PORT_STAT (mac_rx_8192_9216_oct_pkt_num), +HINIC3_PORT_STAT (mac_rx_9217_12287_oct_pkt_num), +HINIC3_PORT_STAT (mac_rx_12288_16383_oct_pkt_num), +HINIC3_PORT_STAT (mac_rx_1519_max_bad_pkt_num), +HINIC3_PORT_STAT (mac_rx_1519_max_good_pkt_num), +HINIC3_PORT_STAT (mac_rx_oversize_pkt_num), +HINIC3_PORT_STAT (mac_rx_jabber_pkt_num), +HINIC3_PORT_STAT (mac_rx_bad_pkt_num), +HINIC3_PORT_STAT (mac_rx_bad_oct_num), +HINIC3_PORT_STAT (mac_rx_good_pkt_num), +HINIC3_PORT_STAT (mac_rx_good_oct_num), +HINIC3_PORT_STAT (mac_rx_total_pkt_num), +HINIC3_PORT_STAT (mac_rx_total_oct_num), +HINIC3_PORT_STAT (mac_rx_uni_pkt_num), +HINIC3_PORT_STAT (mac_rx_multi_pkt_num), +HINIC3_PORT_STAT (mac_rx_broad_pkt_num), +HINIC3_PORT_STAT (mac_rx_pause_num), +HINIC3_PORT_STAT (mac_rx_pfc_pkt_num), +HINIC3_PORT_STAT (mac_rx_pfc_pri0_pkt_num), +HINIC3_PORT_STAT (mac_rx_pfc_pri1_pkt_num), +HINIC3_PORT_STAT (mac_rx_pfc_pri2_pkt_num), +HINIC3_PORT_STAT (mac_rx_pfc_pri3_pkt_num), +HINIC3_PORT_STAT (mac_rx_pfc_pri4_pkt_num), +HINIC3_PORT_STAT (mac_rx_pfc_pri5_pkt_num), +HINIC3_PORT_STAT (mac_rx_pfc_pri6_pkt_num), +HINIC3_PORT_STAT (mac_rx_pfc_pri7_pkt_num), +HINIC3_PORT_STAT (mac_rx_control_pkt_num), +HINIC3_PORT_STAT (mac_rx_sym_err_pkt_num), +HINIC3_PORT_STAT (mac_rx_fcs_err_pkt_num), +HINIC3_PORT_STAT (mac_rx_send_app_good_pkt_num), +HINIC3_PORT_STAT (mac_rx_send_app_bad_pkt_num), +HINIC3_PORT_STAT (mac_rx_unfilter_pkt_num), +}; + +static int hinic3_get_sset_count (struct net_device *netdev,int sset) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +int count, q_num; + +switch (sset) { +case ETH_SS_STATS : + q_num = nic_dev->q_params.num_qps; + count =ARRAY_SIZE (hinic3_netdev_stats) + +ARRAY_SIZE (hinic3_function_stats) + + (ARRAY_SIZE (hinic3_tx_queue_stats) + +ARRAY_SIZE (hinic3_rx_queue_stats)) * + q_num; + +if (!HINIC3_IS_VF (nic_dev->hwdev)) + count +=ARRAY_SIZE (hinic3_port_stats); + +return count; +default : +return -EOPNOTSUPP ; + } +} + +static u64 get_val_of_ptr (u32 size,const void *ptr) +{ +u64 ret = size ==sizeof (u64) ? *(u64 *)ptr : + size ==sizeof (u32) ? *(u32 *)ptr : + size ==sizeof (u16) ? *(u16 *)ptr : + *(u8 *)ptr; + +return ret; +} + +static void hinic3_get_drv_queue_stats (struct net_device *netdev,u64 *data) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +struct hinic3_txq_stats txq_stats = {}; +struct hinic3_rxq_stats rxq_stats = {}; +u16 i =0 , j, qid; +char *p; + +for (qid =0 ; qid < nic_dev->q_params.num_qps; qid++) { +if (!nic_dev->txqs) +break ; + +hinic3_txq_get_stats (&nic_dev->txqs[qid], &txq_stats); +for (j =0 ; j <ARRAY_SIZE (hinic3_tx_queue_stats); j++, i++) { + p = (char *)&txq_stats + + hinic3_tx_queue_stats[j].offset; + data[i] =get_val_of_ptr (hinic3_tx_queue_stats[j].size, + p); + } + } + +for (qid =0 ; qid < nic_dev->q_params.num_qps; qid++) { +if (!nic_dev->rxqs) +break ; + +hinic3_rxq_get_stats (&nic_dev->rxqs[qid], &rxq_stats); +for (j =0 ; j <ARRAY_SIZE (hinic3_rx_queue_stats); j++, i++) { + p = (char *)&rxq_stats + + hinic3_rx_queue_stats[j].offset; + data[i] =get_val_of_ptr (hinic3_rx_queue_stats[j].size, + p); + } + } +} + +static u16 hinic3_get_ethtool_port_stats (struct net_device *netdev,u64 *data) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +struct mag_cmd_port_stats *port_stats; +u16 i =0 , j; +char *p; +int err; + + port_stats =kmalloc_obj (*port_stats,GFP_KERNEL ); +if (!port_stats) { +memset (&data[i],0 , +ARRAY_SIZE (hinic3_port_stats) *sizeof (*data)); + i +=ARRAY_SIZE (hinic3_port_stats); +return i; + } + + err =hinic3_get_phy_port_stats (nic_dev->hwdev, port_stats); +if (err) +netdev_err (netdev,"Failed to get port stats from fw\n" ); + +for (j =0 ; j <ARRAY_SIZE (hinic3_port_stats); j++, i++) { + p = (char *)port_stats + hinic3_port_stats[j].offset; + data[i] =get_val_of_ptr (hinic3_port_stats[j].size, p); + } + +kfree (port_stats); + +return i; +} + +static void hinic3_get_ethtool_stats (struct net_device *netdev, +struct ethtool_stats *stats,u64 *data) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +struct l2nic_vport_stats vport_stats = {}; +const struct rtnl_link_stats64 *net_stats; +struct rtnl_link_stats64 temp; +u16 i =0 , j; +char *p; +int err; + + net_stats =dev_get_stats (netdev, &temp); +for (j =0 ; j <ARRAY_SIZE (hinic3_netdev_stats); j++, i++) { + p = (char *)net_stats + hinic3_netdev_stats[j].offset; + data[i] =get_val_of_ptr (hinic3_netdev_stats[j].size, p); + } + + err =hinic3_get_vport_stats (nic_dev->hwdev, +hinic3_global_func_id (nic_dev->hwdev), + &vport_stats); +if (err) +netdev_err (netdev,"Failed to get function stats from fw\n" ); + +for (j =0 ; j <ARRAY_SIZE (hinic3_function_stats); j++, i++) { + p = (char *)&vport_stats + hinic3_function_stats[j].offset; + data[i] =get_val_of_ptr (hinic3_function_stats[j].size, p); + } + +if (!HINIC3_IS_VF (nic_dev->hwdev)) + i +=hinic3_get_ethtool_port_stats (netdev, data + i); + +hinic3_get_drv_queue_stats (netdev, data + i); +} + +static u16 hinic3_get_drv_dev_strings (char *p) +{ +u16 i, cnt =0 ; + +for (i =0 ; i <ARRAY_SIZE (hinic3_netdev_stats); i++) { +memcpy (p, hinic3_netdev_stats[i].name,ETH_GSTRING_LEN ); + p +=ETH_GSTRING_LEN ; + cnt++; + } + +return cnt; +} + +static u16 hinic3_get_hw_stats_strings (struct net_device *netdev,char *p) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +u16 i, cnt =0 ; + +for (i =0 ; i <ARRAY_SIZE (hinic3_function_stats); i++) { +memcpy (p, hinic3_function_stats[i].name,ETH_GSTRING_LEN ); + p +=ETH_GSTRING_LEN ; + cnt++; + } + +if (!HINIC3_IS_VF (nic_dev->hwdev)) { +for (i =0 ; i <ARRAY_SIZE (hinic3_port_stats); i++) { +memcpy (p, hinic3_port_stats[i].name,ETH_GSTRING_LEN ); + p +=ETH_GSTRING_LEN ; + cnt++; + } + } + +return cnt; +} + +static void hinic3_get_qp_stats_strings (const struct net_device *netdev, +char *p) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +u8 *data = p; +u16 i, j; + +for (i =0 ; i < nic_dev->q_params.num_qps; i++) { +for (j =0 ; j <ARRAY_SIZE (hinic3_tx_queue_stats); j++) +ethtool_sprintf (&data, + hinic3_tx_queue_stats[j].name, i); + } + +for (i =0 ; i < nic_dev->q_params.num_qps; i++) { +for (j =0 ; j <ARRAY_SIZE (hinic3_rx_queue_stats); j++) +ethtool_sprintf (&data, + hinic3_rx_queue_stats[j].name, i); + } +} + +static void hinic3_get_strings (struct net_device *netdev, +u32 stringset,u8 *data) +{ +char *p = (char *)data; +u16 offset; + +switch (stringset) { +case ETH_SS_STATS : + offset =hinic3_get_drv_dev_strings (p); + offset +=hinic3_get_hw_stats_strings (netdev, p + + offset * +ETH_GSTRING_LEN ); +hinic3_get_qp_stats_strings (netdev, + p + offset *ETH_GSTRING_LEN ); + +return ; +default : +netdev_err (netdev,"Invalid string set %u.\n" , stringset); +return ; + } +} +static const struct ethtool_ops hinic3_ethtool_ops = { .supported_coalesce_params =ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_PKT_RATE_RX_USECS ,
@@ -511,6 +922,9 @@ static const struct ethtool_ops hinic3_ethtool_ops = { .get_link = ethtool_op_get_link, .get_ringparam = hinic3_get_ringparam, .set_ringparam = hinic3_set_ringparam, + .get_sset_count = hinic3_get_sset_count, + .get_ethtool_stats = hinic3_get_ethtool_stats, + .get_strings = hinic3_get_strings, };void hinic3_set_ethtool_ops (struct net_device *netdev)
drivers/net/ethernet/huawei/hinic3/hinic3_hw_intf.h +12 -1
@@ -51,7 +51,18 @@ static inline void mgmt_msg_params_init_default(struct mgmt_msg_params *msg_para msg_params->in_size = buf_size; msg_params->expected_out_size = buf_size; msg_params->timeout_ms =0 ; -} +}; + +static inline void +mgmt_msg_params_init_in_out (struct mgmt_msg_params *msg_params,void *in_buf, +void *out_buf,u32 in_buf_size,u32 out_buf_size) +{ + msg_params->buf_in = in_buf; + msg_params->buf_out = out_buf; + msg_params->in_size = in_buf_size; + msg_params->expected_out_size = out_buf_size; + msg_params->timeout_ms =0 ; +};enum cfg_cmd {CFG_CMD_GET_DEV_CAP =0 ,
drivers/net/ethernet/huawei/hinic3/hinic3_mgmt_interface.h +37 -0
@@ -143,6 +143,41 @@ struct l2nic_cmd_set_dcb_state {u8 rsvd[7 ]; }; +struct l2nic_port_stats_info { +struct mgmt_msg_head msg_head; +u16 func_id; +u16 rsvd1; +}; + +struct l2nic_vport_stats { +u64 tx_unicast_pkts_vport; +u64 tx_unicast_bytes_vport; +u64 tx_multicast_pkts_vport; +u64 tx_multicast_bytes_vport; +u64 tx_broadcast_pkts_vport; +u64 tx_broadcast_bytes_vport; + +u64 rx_unicast_pkts_vport; +u64 rx_unicast_bytes_vport; +u64 rx_multicast_pkts_vport; +u64 rx_multicast_bytes_vport; +u64 rx_broadcast_pkts_vport; +u64 rx_broadcast_bytes_vport; + +u64 tx_discard_vport; +u64 rx_discard_vport; +u64 tx_err_vport; +u64 rx_err_vport; +}; + +struct l2nic_cmd_vport_stats { +struct mgmt_msg_head msg_head; +u32 stats_size; +u32 rsvd1; +struct l2nic_vport_stats stats; +u64 rsvd2[6 ]; +}; +struct l2nic_cmd_lro_config {struct mgmt_msg_head msg_head;u16 func_id;
@@ -234,6 +269,7 @@ enum l2nic_cmd {L2NIC_CMD_SET_VPORT_ENABLE =6 ,L2NIC_CMD_SET_RX_MODE =7 ,L2NIC_CMD_SET_SQ_CI_ATTR =8 , +L2NIC_CMD_GET_VPORT_STAT =9 ,L2NIC_CMD_CLEAR_QP_RESOURCE =11 ,L2NIC_CMD_CFG_RX_LRO =13 , L2NIC_CMD_CFG_LRO_TIMER = 14,
@@ -272,6 +308,7 @@ enum mag_cmd {MAG_CMD_SET_PORT_ENABLE =6 ,MAG_CMD_GET_LINK_STATUS =7 , +MAG_CMD_GET_PORT_STAT =151 , MAG_CMD_GET_PORT_INFO = 153, };
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c +64 -0
73 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.h +109 -0
121 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_nic_dev.h +15 -0
@@ -34,6 +34,20 @@ enum hinic3_event_work_flags { HINIC3_EVENT_WORK_TX_TIMEOUT, }; +#define HINIC3_NIC_STATS_INC (nic_dev, field) \ +do { \ + u64_stats_update_begin(&(nic_dev)->stats.syncp); \ + (nic_dev)->stats.field++; \ + u64_stats_update_end(&(nic_dev)->stats.syncp); \ +} while (0) + +struct hinic3_nic_stats { +/* Subdivision statistics show in private tool */ +u64 tx_carrier_off_drop; +u64 tx_invalid_qid; +struct u64_stats_sync syncp; +}; +enum hinic3_rx_mode_state {HINIC3_HW_PROMISC_ON ,HINIC3_HW_ALLMULTI_ON ,
@@ -120,6 +134,7 @@ struct hinic3_nic_dev {struct hinic3_dyna_txrxq_params q_params;struct hinic3_txq *txqs;struct hinic3_rxq *rxqs; +struct hinic3_nic_stats stats;enum hinic3_rss_hash_type rss_hash_type;struct hinic3_rss_type rss_type;
drivers/net/ethernet/huawei/hinic3/hinic3_rx.c +54 -4
123 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_rx.h +14 -0
@@ -8,6 +8,17 @@#include <linux/dim.h> #include <linux/netdevice.h> +/* rx cqe checksum err */ +#define HINIC3_RX_CSUM_IP_CSUM_ERR BIT(0) +#define HINIC3_RX_CSUM_TCP_CSUM_ERR BIT(1) +#define HINIC3_RX_CSUM_UDP_CSUM_ERR BIT(2) +#define HINIC3_RX_CSUM_IGMP_CSUM_ERR BIT(3) +#define HINIC3_RX_CSUM_ICMPV4_CSUM_ERR BIT(4) +#define HINIC3_RX_CSUM_ICMPV6_CSUM_ERR BIT(5) +#define HINIC3_RX_CSUM_SCTP_CRC_ERR BIT(6) +#define HINIC3_RX_CSUM_HW_CHECK_NONE BIT(7) +#define HINIC3_RX_CSUM_IPSU_OTHER_ERR BIT(8) +#define RQ_CQE_OFFOLAD_TYPE_PKT_TYPE_MASK GENMASK(4, 0)#define RQ_CQE_OFFOLAD_TYPE_IP_TYPE_MASK GENMASK(6, 5)#define RQ_CQE_OFFOLAD_TYPE_TUNNEL_PKT_FORMAT_MASK GENMASK(11, 8)
@@ -123,6 +134,9 @@ void hinic3_free_rxqs_res(struct net_device *netdev, u16 num_rq, u32 rq_depth, struct hinic3_dyna_rxq_res *rxqs_res);int hinic3_configure_rxqs (struct net_device *netdev,u16 num_rq,u32 rq_depth,struct hinic3_dyna_rxq_res *rxqs_res); + +void hinic3_rxq_get_stats (struct hinic3_rxq *rxq, +struct hinic3_rxq_stats *stats);int hinic3_rx_poll (struct hinic3_rxq *rxq,int budget);#endif
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c +68 -4
138 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_tx.h +2 -0
@@ -157,6 +157,8 @@ int hinic3_configure_txqs(struct net_device *netdev, u16 num_sq, u32 sq_depth, struct hinic3_dyna_txq_res *txqs_res);netdev_tx_t hinic3_xmit_frame (struct sk_buff *skb,struct net_device *netdev); +void hinic3_txq_get_stats (struct hinic3_txq *txq, +struct hinic3_txq_stats *stats);bool hinic3_tx_poll (struct hinic3_txq *txq,int budget);void hinic3_flush_txqs (struct net_device *netdev);
Signature · 1 line
2.43.0
Re: [PATCH net-next v01 11/15] hinic3: Add ethtool statistic ops
Quoted 20 lines · Fan Gong
Co-developed-by Zhu Yikai <[email protected]>Signed-off-by Zhu Yikai <[email protected]>Signed-off-by Fan Gong <[email protected]>--- .../ethernet/huawei/hinic3/hinic3_ethtool.c | 414 ++++++++++++++++++ .../ethernet/huawei/hinic3/hinic3_hw_intf.h | 13 +- .../huawei/hinic3/hinic3_mgmt_interface.h | 37 ++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 64 +++ .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 109 +++++ .../ethernet/huawei/hinic3/hinic3_nic_dev.h | 15 + .../net/ethernet/huawei/hinic3/hinic3_rx.c | 58 ++- .../net/ethernet/huawei/hinic3/hinic3_rx.h | 14 + .../net/ethernet/huawei/hinic3/hinic3_tx.c | 72 ++- .../net/ethernet/huawei/hinic3/hinic3_tx.h | 2 + 10 files changed, 789 insertions(+), 9 deletions(-)drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c +0
-0
(...)
Quoted 11 lines
drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c +11
-0+ +static struct hinic3_stats hinic3_port_stats[] = { +HINIC3_PORT_STAT (mac_tx_fragment_pkt_num), +HINIC3_PORT_STAT (mac_tx_undersize_pkt_num), +HINIC3_PORT_STAT (mac_tx_undermin_pkt_num), +HINIC3_PORT_STAT (mac_tx_64_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_65_127_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_128_255_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_256_511_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_512_1023_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_1024_1518_oct_pkt_num),
drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c static int hinic3_set_ringparam(struct net_device *netdev, · line 635
Quoted 10 lines
drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c +10
-0+HINIC3_PORT_STAT (mac_tx_1519_2047_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_2048_4095_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_4096_8191_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_8192_9216_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_9217_12287_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_12288_16383_oct_pkt_num), +HINIC3_PORT_STAT (mac_tx_1519_max_bad_pkt_num), +HINIC3_PORT_STAT (mac_tx_1519_max_good_pkt_num), +HINIC3_PORT_STAT (mac_tx_oversize_pkt_num), + HINIC3_PORT_STAT(mac_tx_jabber_pkt_num),
These look like rmon statistics that should be exported through the ethtool .get_rmon_stats() callback.
Quoted 13 lines
drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c +13
-0+HINIC3_PORT_STAT (mac_tx_bad_pkt_num), +HINIC3_PORT_STAT (mac_tx_bad_oct_num), +HINIC3_PORT_STAT (mac_tx_good_pkt_num), +HINIC3_PORT_STAT (mac_tx_good_oct_num), +HINIC3_PORT_STAT (mac_tx_total_pkt_num), +HINIC3_PORT_STAT (mac_tx_total_oct_num), +HINIC3_PORT_STAT (mac_tx_uni_pkt_num), +HINIC3_PORT_STAT (mac_tx_multi_pkt_num), +HINIC3_PORT_STAT (mac_tx_broad_pkt_num), +HINIC3_PORT_STAT (mac_tx_pause_num), +HINIC3_PORT_STAT (mac_tx_pfc_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri0_pkt_num), + HINIC3_PORT_STAT(mac_tx_pfc_pri1_pkt_num),
drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c static int hinic3_set_ringparam(struct net_device *netdev, · line 658
Quoted 10 lines
drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c +10
-0+HINIC3_PORT_STAT (mac_tx_pfc_pri2_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri3_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri4_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri5_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri6_pkt_num), +HINIC3_PORT_STAT (mac_tx_pfc_pri7_pkt_num), +HINIC3_PORT_STAT (mac_tx_control_pkt_num), +HINIC3_PORT_STAT (mac_tx_err_all_pkt_num), +HINIC3_PORT_STAT (mac_tx_from_app_good_pkt_num), + HINIC3_PORT_STAT(mac_tx_from_app_bad_pkt_num),
Please have a look also at the following ethtool callbacks and see if you can export any other counters through the standardized method.
* @get_pause_stats: Report pause frame statistics. Drivers must not zero
* statistics which they don't report. The stats structure is initialized
* to ETHTOOL_STAT_NOT_SET indicating driver does not report statistics.
* @get_eth_phy_stats: Query some of the IEEE 802.3 PHY statistics.
* @get_eth_mac_stats: Query some of the IEEE 802.3 MAC statistics.
* @get_eth_ctrl_stats: Query some of the IEEE 802.3 MAC Ctrl statistics.
Ioana
Fan Gong
maintainerPATCH 12/15 hinic3: Add ethtool coalesce ops
In reply to Fan Gong--- .../ethernet/huawei/hinic3/hinic3_ethtool.c | 275 ++++++++++++++++++ 1 file changed, 275 insertions(+)
drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c +275 -0
@@ -17,6 +17,12 @@#include "hinic3_nic_cfg.h" #define HINIC3_MGMT_VERSION_MAX_LEN 32 +#define COALESCE_ALL_QUEUE 0xFFFF +/* Coalesce time properties in milliseconds */ +#define COALESCE_PENDING_LIMIT_UNIT 8 +#define COALESCE_TIMER_CFG_UNIT 5 +#define COALESCE_MAX_PENDING_LIMIT (255 * COALESCE_PENDING_LIMIT_UNIT) +#define COALESCE_MAX_TIMER_CFG (255 * COALESCE_TIMER_CFG_UNIT)static void hinic3_get_drvinfo (struct net_device *netdev,struct ethtool_drvinfo *info)
@@ -912,6 +918,273 @@ static void hinic3_get_strings(struct net_device *netdev, } } +static int hinic3_set_queue_coalesce (struct net_device *netdev,u16 q_id, +struct hinic3_intr_coal_info *coal) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +struct hinic3_intr_coal_info *intr_coal; +struct hinic3_interrupt_info info = {}; +int err; + + intr_coal = &nic_dev->intr_coalesce[q_id]; + + intr_coal->coalesce_timer_cfg = coal->coalesce_timer_cfg; + intr_coal->pending_limit = coal->pending_limit; + intr_coal->rx_pending_limit_low = coal->rx_pending_limit_low; + intr_coal->rx_pending_limit_high = coal->rx_pending_limit_high; + +if (!test_bit (HINIC3_INTF_UP , &nic_dev->flags) || + q_id >= nic_dev->q_params.num_qps || nic_dev->adaptive_rx_coal) +return 0 ; + + info.msix_index = nic_dev->q_params.irq_cfg[q_id].msix_entry_idx; + info.interrupt_coalesc_set =1 ; + info.coalesc_timer_cfg = intr_coal->coalesce_timer_cfg; + info.pending_limit = intr_coal->pending_limit; + info.resend_timer_cfg = intr_coal->resend_timer_cfg; + err =hinic3_set_interrupt_cfg (nic_dev->hwdev, info); +if (err) { +netdev_warn (netdev,"Failed to set queue%u coalesce\n" , q_id); +return err; + } + +return 0 ; +} + +static int is_coalesce_exceed_limit (struct net_device *netdev, +const struct ethtool_coalesce *coal) +{ +if (coal->rx_coalesce_usecs >COALESCE_MAX_TIMER_CFG ) { +netdev_err (netdev,"rx_coalesce_usecs out of range %d-%d\n" ,0 , +COALESCE_MAX_TIMER_CFG ); +return -EOPNOTSUPP ; + } + +if (coal->rx_max_coalesced_frames >COALESCE_MAX_PENDING_LIMIT ) { +netdev_err (netdev,"rx_max_coalesced_frames out of range %d-%d\n" , +0 ,COALESCE_MAX_PENDING_LIMIT ); +return -EOPNOTSUPP ; + } + +if (coal->rx_coalesce_usecs_low >COALESCE_MAX_TIMER_CFG ) { +netdev_err (netdev,"rx_coalesce_usecs_low out of range %d-%d\n" , +0 ,COALESCE_MAX_TIMER_CFG ); +return -EOPNOTSUPP ; + } + +if (coal->rx_max_coalesced_frames_low >COALESCE_MAX_PENDING_LIMIT ) { +netdev_err (netdev,"rx_max_coalesced_frames_low out of range %d-%d\n" , +0 ,COALESCE_MAX_PENDING_LIMIT ); +return -EOPNOTSUPP ; + } + +if (coal->rx_coalesce_usecs_high >COALESCE_MAX_TIMER_CFG ) { +netdev_err (netdev,"rx_coalesce_usecs_high out of range %d-%d\n" , +0 ,COALESCE_MAX_TIMER_CFG ); +return -EOPNOTSUPP ; + } + +if (coal->rx_max_coalesced_frames_high >COALESCE_MAX_PENDING_LIMIT ) { +netdev_err (netdev,"rx_max_coalesced_frames_high out of range %d-%d\n" , +0 ,COALESCE_MAX_PENDING_LIMIT ); +return -EOPNOTSUPP ; + } + +return 0 ; +} + +static int is_coalesce_legal (struct net_device *netdev, +const struct ethtool_coalesce *coal) +{ +struct ethtool_coalesce tmp_coal = {}; +int err; + +if (coal->rx_coalesce_usecs != coal->tx_coalesce_usecs) { +netdev_err (netdev,"tx-usecs must be equal to rx-usecs\n" ); +return -EINVAL ; + } + +if (coal->rx_max_coalesced_frames != coal->tx_max_coalesced_frames) { +netdev_err (netdev,"tx-frames must be equal to rx-frames\n" ); +return -EINVAL ; + } + + tmp_coal.cmd = coal->cmd; + tmp_coal.rx_coalesce_usecs = coal->rx_coalesce_usecs; + tmp_coal.rx_max_coalesced_frames = coal->rx_max_coalesced_frames; + tmp_coal.tx_coalesce_usecs = coal->tx_coalesce_usecs; + tmp_coal.tx_max_coalesced_frames = coal->tx_max_coalesced_frames; + tmp_coal.use_adaptive_rx_coalesce = coal->use_adaptive_rx_coalesce; + + tmp_coal.rx_coalesce_usecs_low = coal->rx_coalesce_usecs_low; + tmp_coal.rx_max_coalesced_frames_low = + coal->rx_max_coalesced_frames_low; + + tmp_coal.rx_coalesce_usecs_high = coal->rx_coalesce_usecs_high; + tmp_coal.rx_max_coalesced_frames_high = + coal->rx_max_coalesced_frames_high; + +if (memcmp (coal, &tmp_coal,sizeof (struct ethtool_coalesce ))) { +netdev_err (netdev,"Only support to change rx/tx-usecs and rx/tx-frames\n" ); +return -EOPNOTSUPP ; + } + + err =is_coalesce_exceed_limit (netdev, coal); +if (err) +return err; + +if (coal->rx_coalesce_usecs_low /COALESCE_TIMER_CFG_UNIT >= + coal->rx_coalesce_usecs_high /COALESCE_TIMER_CFG_UNIT ) { +netdev_err (netdev,"invalid coalesce usec high %u, low %u, unit %d\n" , + coal->rx_coalesce_usecs_high, + coal->rx_coalesce_usecs_low, +COALESCE_TIMER_CFG_UNIT ); +return -EINVAL ; + } + +if (coal->rx_max_coalesced_frames_low /COALESCE_PENDING_LIMIT_UNIT >= + coal->rx_max_coalesced_frames_high /COALESCE_PENDING_LIMIT_UNIT ) { +netdev_err (netdev,"invalid coalesce frame high %u, low %u, unit %d\n" , + coal->rx_max_coalesced_frames_high, + coal->rx_max_coalesced_frames_low, +COALESCE_PENDING_LIMIT_UNIT ); +return -EOPNOTSUPP ; + } + +return 0 ; +} + +static void check_coalesce_align (struct net_device *netdev, +u32 item,u32 unit,const char *str) +{ +if (item % unit) +netdev_warn (netdev,"%s in %d units, change to %u\n" , + str, unit, item - item % unit); +} + +#define CHECK_COALESCE_ALIGN (member, unit) \ + check_coalesce_align(netdev, member, unit, #member) + +static void check_coalesce_changed (struct net_device *netdev, +u32 item,u32 unit,u32 ori_val, +const char *obj_str,const char *str) +{ +if ((item / unit) != ori_val) +netdev_dbg (netdev,"Change %s from %d to %u %s\n" , + str, ori_val * unit, item - item % unit, obj_str); +} + +#define CHECK_COALESCE_CHANGED (member, unit, ori_val, obj_str) \ + check_coalesce_changed(netdev, member, unit, ori_val, obj_str, #member) + +static int hinic3_set_hw_coal_param (struct net_device *netdev, +struct hinic3_intr_coal_info *intr_coal) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +u16 i; + +for (i =0 ; i < nic_dev->max_qps; i++) +hinic3_set_queue_coalesce (netdev, i, intr_coal); + +return 0 ; +} + +static int hinic3_get_coalesce (struct net_device *netdev, +struct ethtool_coalesce *coal, +struct kernel_ethtool_coalesce *kernel_coal, +struct netlink_ext_ack *extack) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +struct hinic3_intr_coal_info *interrupt_info; + + interrupt_info = &nic_dev->intr_coalesce[0 ]; + + coal->rx_coalesce_usecs = interrupt_info->coalesce_timer_cfg * +COALESCE_TIMER_CFG_UNIT ; + coal->rx_max_coalesced_frames = interrupt_info->pending_limit * +COALESCE_PENDING_LIMIT_UNIT ; + +/* tx/rx use the same interrupt */ + coal->tx_coalesce_usecs = coal->rx_coalesce_usecs; + coal->tx_max_coalesced_frames = coal->rx_max_coalesced_frames; + coal->use_adaptive_rx_coalesce = nic_dev->adaptive_rx_coal; + + coal->rx_max_coalesced_frames_high = + interrupt_info->rx_pending_limit_high * +COALESCE_PENDING_LIMIT_UNIT ; + + coal->rx_max_coalesced_frames_low = + interrupt_info->rx_pending_limit_low * +COALESCE_PENDING_LIMIT_UNIT ; + +return 0 ; +} + +static int hinic3_set_coalesce (struct net_device *netdev, +struct ethtool_coalesce *coal, +struct kernel_ethtool_coalesce *kernel_coal, +struct netlink_ext_ack *extack) +{ +struct hinic3_nic_dev *nic_dev =netdev_priv (netdev); +struct hinic3_intr_coal_info *ori_intr_coal; +struct hinic3_intr_coal_info intr_coal = {}; +char obj_str[32 ]; +int err; + + err =is_coalesce_legal (netdev, coal); +if (err) +return err; + +CHECK_COALESCE_ALIGN (coal->rx_coalesce_usecs,COALESCE_TIMER_CFG_UNIT ); +CHECK_COALESCE_ALIGN (coal->rx_max_coalesced_frames, +COALESCE_PENDING_LIMIT_UNIT ); +CHECK_COALESCE_ALIGN (coal->rx_coalesce_usecs_high, +COALESCE_TIMER_CFG_UNIT ); +CHECK_COALESCE_ALIGN (coal->rx_max_coalesced_frames_high, +COALESCE_PENDING_LIMIT_UNIT ); +CHECK_COALESCE_ALIGN (coal->rx_coalesce_usecs_low, +COALESCE_TIMER_CFG_UNIT ); +CHECK_COALESCE_ALIGN (coal->rx_max_coalesced_frames_low, +COALESCE_PENDING_LIMIT_UNIT ); + + ori_intr_coal = &nic_dev->intr_coalesce[0 ]; +snprintf (obj_str,sizeof (obj_str),"for netdev" ); + +CHECK_COALESCE_CHANGED (coal->rx_coalesce_usecs,COALESCE_TIMER_CFG_UNIT , + ori_intr_coal->coalesce_timer_cfg, obj_str); +CHECK_COALESCE_CHANGED (coal->rx_max_coalesced_frames, +COALESCE_PENDING_LIMIT_UNIT , + ori_intr_coal->pending_limit, obj_str); +CHECK_COALESCE_CHANGED (coal->rx_max_coalesced_frames_high, +COALESCE_PENDING_LIMIT_UNIT , + ori_intr_coal->rx_pending_limit_high, obj_str); +CHECK_COALESCE_CHANGED (coal->rx_max_coalesced_frames_low, +COALESCE_PENDING_LIMIT_UNIT , + ori_intr_coal->rx_pending_limit_low, obj_str); + + intr_coal.coalesce_timer_cfg = + (u8)(coal->rx_coalesce_usecs /COALESCE_TIMER_CFG_UNIT ); + intr_coal.pending_limit = (u8)(coal->rx_max_coalesced_frames / +COALESCE_PENDING_LIMIT_UNIT ); + + nic_dev->adaptive_rx_coal = coal->use_adaptive_rx_coalesce; + + intr_coal.rx_pending_limit_high = + (u8)(coal->rx_max_coalesced_frames_high / +COALESCE_PENDING_LIMIT_UNIT ); + + intr_coal.rx_pending_limit_low = + (u8)(coal->rx_max_coalesced_frames_low / +COALESCE_PENDING_LIMIT_UNIT ); + +/* coalesce timer or pending set to zero will disable coalesce */ +if (!nic_dev->adaptive_rx_coal && + (!intr_coal.coalesce_timer_cfg || !intr_coal.pending_limit)) +netdev_warn (netdev,"Coalesce will be disabled\n" ); + +return hinic3_set_hw_coal_param (netdev, &intr_coal); +} +static const struct ethtool_ops hinic3_ethtool_ops = { .supported_coalesce_params =ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_PKT_RATE_RX_USECS ,
@@ -925,6 +1198,8 @@ static const struct ethtool_ops hinic3_ethtool_ops = { .get_sset_count = hinic3_get_sset_count, .get_ethtool_stats = hinic3_get_ethtool_stats, .get_strings = hinic3_get_strings, + .get_coalesce = hinic3_get_coalesce, + .set_coalesce = hinic3_set_coalesce, };void hinic3_set_ethtool_ops (struct net_device *netdev)
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 13/15 hinic3: Add ethtool rss ops
In reply to Fan Gong--- .../ethernet/huawei/hinic3/hinic3_ethtool.c | 9 + .../huawei/hinic3/hinic3_mgmt_interface.h | 2 + .../net/ethernet/huawei/hinic3/hinic3_rss.c | 485 +++++++++++++++++- .../net/ethernet/huawei/hinic3/hinic3_rss.h | 19 + 4 files changed, 514 insertions(+), 1 deletion(-)
drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c +9 -0
@@ -15,6 +15,7 @@#include "hinic3_hw_comm.h" #include "hinic3_nic_dev.h" #include "hinic3_nic_cfg.h" +#include "hinic3_rss.h" #define HINIC3_MGMT_VERSION_MAX_LEN 32#define COALESCE_ALL_QUEUE 0xFFFF
@@ -1200,6 +1201,14 @@ static const struct ethtool_ops hinic3_ethtool_ops = { .get_strings = hinic3_get_strings, .get_coalesce = hinic3_get_coalesce, .set_coalesce = hinic3_set_coalesce, + .get_rxnfc = hinic3_get_rxnfc, + .set_rxnfc = hinic3_set_rxnfc, + .get_channels = hinic3_get_channels, + .set_channels = hinic3_set_channels, + .get_rxfh_indir_size = hinic3_get_rxfh_indir_size, + .get_rxfh_key_size = hinic3_get_rxfh_key_size, + .get_rxfh = hinic3_get_rxfh, + .set_rxfh = hinic3_set_rxfh, };void hinic3_set_ethtool_ops (struct net_device *netdev)
drivers/net/ethernet/huawei/hinic3/hinic3_mgmt_interface.h +2 -0
@@ -282,6 +282,7 @@ enum l2nic_cmd {L2NIC_CMD_SET_VLAN_FILTER_EN =26 ,L2NIC_CMD_SET_RX_VLAN_OFFLOAD =27 ,L2NIC_CMD_CFG_RSS =60 , +L2NIC_CMD_GET_RSS_CTX_TBL =62 ,L2NIC_CMD_CFG_RSS_HASH_KEY =63 ,L2NIC_CMD_CFG_RSS_HASH_ENGINE =64 , L2NIC_CMD_SET_RSS_CTX_TBL = 65,
@@ -301,6 +302,7 @@ enum l2nic_ucode_cmd {L2NIC_UCODE_CMD_MODIFY_QUEUE_CTX =0 ,L2NIC_UCODE_CMD_CLEAN_QUEUE_CTX =1 ,L2NIC_UCODE_CMD_SET_RSS_INDIR_TBL =4 , + L2NIC_UCODE_CMD_GET_RSS_INDIR_TBL = 6, };/* hilink mac group command */
drivers/net/ethernet/huawei/hinic3/hinic3_rss.c +484 -1
500 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic3/hinic3_rss.h +19 -0
@@ -5,10 +5,29 @@#define _HINIC3_RSS_H_#include <linux/netdevice.h> +#include <linux/ethtool.h> int hinic3_rss_init (struct net_device *netdev);void hinic3_rss_uninit (struct net_device *netdev);void hinic3_try_to_enable_rss (struct net_device *netdev);void hinic3_clear_rss_config (struct net_device *netdev); +int hinic3_get_rxnfc (struct net_device *netdev, +struct ethtool_rxnfc *cmd,u32 *rule_locs); +int hinic3_set_rxnfc (struct net_device *netdev,struct ethtool_rxnfc *cmd); + +void hinic3_get_channels (struct net_device *netdev, +struct ethtool_channels *channels); +int hinic3_set_channels (struct net_device *netdev, +struct ethtool_channels *channels); + +u32 hinic3_get_rxfh_indir_size (struct net_device *netdev); +u32 hinic3_get_rxfh_key_size (struct net_device *netdev); + +int hinic3_get_rxfh (struct net_device *netdev, +struct ethtool_rxfh_param *rxfh); +int hinic3_set_rxfh (struct net_device *netdev, +struct ethtool_rxfh_param *rxfh, +struct netlink_ext_ack *extack); +#endif
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 14/15 hinic3: Add MTU size validation
In reply to Fan Gong--- drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c +13 -0
@@ -246,6 +246,19 @@ int hinic3_set_port_mtu(struct net_device *netdev, u16 new_mtu)struct l2nic_func_tbl_cfg func_tbl_cfg = {};struct hinic3_hwdev *hwdev = nic_dev->hwdev; +if (new_mtu <HINIC3_MIN_MTU_SIZE ) { +dev_err (hwdev->dev, +"Invalid mtu size: %ubytes, mtu size < %ubytes\n" , + new_mtu,HINIC3_MIN_MTU_SIZE ); +return -EINVAL ; + } + +if (new_mtu >HINIC3_MAX_JUMBO_FRAME_SIZE ) { +dev_err (hwdev->dev,"Invalid mtu size: %ubytes, mtu size > %ubytes\n" , + new_mtu,HINIC3_MAX_JUMBO_FRAME_SIZE ); +return -EINVAL ; + } + func_tbl_cfg.mtu = new_mtu; return hinic3_set_function_table(hwdev, BIT(L2NIC_FUNC_TBL_CFG_MTU),
Signature · 1 line
2.43.0
Fan Gong
maintainerPATCH 15/15 hinic3: Config netdev->watchdog_timeo to set nic tx timeout
In reply to Fan Gong--- drivers/net/ethernet/huawei/hinic3/hinic3_main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/huawei/hinic3/hinic3_main.c +4 -0
@@ -33,6 +33,8 @@#define HINIC3_RX_PENDING_LIMIT_LOW 2#define HINIC3_RX_PENDING_LIMIT_HIGH 8 +#define HINIC3_WATCHDOG_TIMEOUT 5 +static void init_intr_coal_param (struct net_device *netdev) {struct hinic3_nic_dev *nic_dev =netdev_priv (netdev);
@@ -245,6 +247,8 @@ static void hinic3_assign_netdev_ops(struct net_device *netdev) {hinic3_set_netdev_ops (netdev);hinic3_set_ethtool_ops (netdev); + + netdev->watchdog_timeo =HINIC3_WATCHDOG_TIMEOUT *HZ ; }static void netdev_feature_init (struct net_device *netdev)
Signature · 1 line
2.43.0
Fan Gong
maintainerQuoted 9 lines · Fan Gong
This patchset provides 4 code styles fixes:
Remove empty lines between error handling. Remove defensive
txq_numcheck.
Usearray_sizeinstead of multiplying.
SQ useSQ_CTXT_PREF_CI_HIto improve readability.Changes:
Quoted 7 lines
PATCH V01: https://lore.kernel.org/netdev/[email protected]/
PATCH V02: https://lore.kernel.org/netdev/[email protected]/
* Send "Fixnetif_queue_set_napiqueue_indexparameter passing error" to net (Jakub Kicinski)PATCH V03:
* Modify commit description to be more accurate and clear (Simon Horman)
Sorry for forgetting to replace cover letter to a newer one.
We will send the next version with correct cover letter and commit contexts, and refer to possible AI review for revisions after 24 hours.
Thanks,
Fan Gong
Jakub Kicinski
maintainerQuoted 3 lines · On Tue, 24 Feb 2026 21:43:15 +0800 Fan Gong wrote:
Sorry for forgetting to replace cover letter to a newer one.
We will send the next version with correct cover letter and commit contexts, and refer to possible AI review for revisions after 24 hours.
FWIW the AI review is here:
https://netdev-ai.bots.linux.dev/ai-review.html?id=199da9b3-7cc5-40ef-b5d0-e8073e3eb49f
The LLM timed out for one of the patches so it won't get published to patchwork.
Another note - could you perhaps cut this series down? You're adding a bunch of features and:
34 files changed, 2985 insertions(+), 29 deletions(-)
Not too bad, but I still think you'd make faster progress with a smaller series.
Fan Gong
maintainerQuoted 11 lines · Jakub Kicinski
The LLM timed out for one of the patches so it won't get published to patchwork.
Another note - could you perhaps cut this series down? You're adding a bunch of features and:
34 files changed, 2985 insertions(+), 29 deletions(-)Not too bad, but I still think you'd make faster progress with a smaller series.
Thanks for the review. We'll split the series into smaller patchsets and modify the code based on the reviews of Ioana, patchwork checkes and AI.
Fan gong