1.Remove unused functions about ceq 2.Remove unused clp hardware channels 3.Remove the code of polling mode 4.Remove the code about little endian and big endian conversion
Yanling Song (4): net/spnic:Remove unused functions about ceq net/spnic:Remove unused clp hardware channels net/spnic:Remove the code of polling mode net/spnic:Remove the code about little endian and big endian conversion
.../net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c | 58 +-- .../ethernet/ramaxel/spnic/hw/sphw_common.h | 12 - .../net/ethernet/ramaxel/spnic/hw/sphw_crm.h | 2 - .../net/ethernet/ramaxel/spnic/hw/sphw_csr.h | 13 - .../net/ethernet/ramaxel/spnic/hw/sphw_eqs.c | 104 +--- .../net/ethernet/ramaxel/spnic/hw/sphw_hw.h | 2 - .../ethernet/ramaxel/spnic/hw/sphw_hwdev.c | 31 -- .../ethernet/ramaxel/spnic/hw/sphw_hwdev.h | 2 - .../net/ethernet/ramaxel/spnic/hw/sphw_hwif.c | 27 +- .../net/ethernet/ramaxel/spnic/hw/sphw_mbox.c | 20 +- .../net/ethernet/ramaxel/spnic/hw/sphw_mbox.h | 2 - .../net/ethernet/ramaxel/spnic/hw/sphw_mgmt.c | 487 ------------------ .../net/ethernet/ramaxel/spnic/hw/sphw_mgmt.h | 50 -- .../net/ethernet/ramaxel/spnic/hw/sphw_mt.h | 1 - .../net/ethernet/ramaxel/spnic/spnic_nic_io.h | 6 +- .../net/ethernet/ramaxel/spnic/spnic_nic_qp.h | 7 +- drivers/net/ethernet/ramaxel/spnic/spnic_rx.c | 39 +- drivers/net/ethernet/ramaxel/spnic/spnic_tx.c | 20 +- 18 files changed, 41 insertions(+), 842 deletions(-)
Ramaxel inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4P01N CVE: NA
Remove unused functions about ceq since the code just defined but never used in the driver.
Signed-off-by: Yanling Song songyl@ramaxel.com Reviewed-by: Yang Gan yanggan@ramaxel.com --- .../net/ethernet/ramaxel/spnic/hw/sphw_eqs.c | 97 ------------------- .../net/ethernet/ramaxel/spnic/hw/sphw_hwif.c | 27 +----- .../net/ethernet/ramaxel/spnic/hw/sphw_mbox.c | 18 ---- .../net/ethernet/ramaxel/spnic/hw/sphw_mbox.h | 2 - 4 files changed, 1 insertion(+), 143 deletions(-)
diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_eqs.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_eqs.c index e0c84c5bcc58..8f71d9de76c1 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_eqs.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_eqs.c @@ -595,43 +595,6 @@ static bool eq_irq_handler(void *data) return uncompleted; }
-static struct sphw_eq *find_eq(struct sphw_hwdev *hwdev, int msix_entry_idx) -{ - struct sphw_aeqs *aeqs = hwdev->aeqs; - struct sphw_ceqs *ceqs = hwdev->ceqs; - int i; - - for (i = 0; i < aeqs->num_aeqs; i++) { - struct sphw_eq *eq = &aeqs->aeq[i]; - - if (eq->eq_irq.msix_entry_idx == msix_entry_idx) - return eq; - } - - for (i = 0; i < ceqs->num_ceqs; i++) { - struct sphw_eq *eq = &ceqs->ceq[i]; - - if (eq->eq_irq.msix_entry_idx == msix_entry_idx) - return eq; - } - - return NULL; -} - -/* for windows */ -bool sphw_eq_intr_handler(void *hwdev, int msix_entry_idx) -{ - struct sphw_eq *eq; - - eq = find_eq(hwdev, msix_entry_idx); - if (!eq) { - pr_err("Can't find eq in eq interrupt handler\n"); - return false; - } - - return eq_irq_handler(eq); -} - /** * eq_irq_work - eq work for the event * @work: the work that is associated with the eq @@ -1312,63 +1275,3 @@ void sphw_dump_ceq_info(struct sphw_hwdev *hwdev) jiffies_to_msecs(jiffies - eq->soft_intr_jif)); } } - -int sphw_get_ceq_info(void *hwdev, u16 q_id, struct sphw_ceq_info *ceq_info) -{ - struct sphw_hwdev *dev = hwdev; - struct sphw_eq *eq = NULL; - - if (!hwdev || !ceq_info) - return -EINVAL; - - if (q_id >= dev->ceqs->num_ceqs) - return -EINVAL; - - eq = &dev->ceqs->ceq[q_id]; - ceq_info->q_len = eq->eq_len; - ceq_info->num_pages = eq->num_pages; - ceq_info->page_size = eq->page_size; - ceq_info->num_elem_in_pg = eq->num_elem_in_pg; - ceq_info->elem_size = eq->elem_size; - sdk_info(dev->dev_hdl, "get_ceq_info: qid=0x%x page_size=%ul\n", - q_id, eq->page_size); - - return 0; -} - -int sphw_get_ceq_page_phy_addr(void *hwdev, u16 q_id, u16 page_idx, u64 *page_phy_addr) -{ - struct sphw_hwdev *dev = hwdev; - struct sphw_eq *eq = NULL; - - if (!hwdev || !page_phy_addr) - return -EINVAL; - - if (q_id >= dev->ceqs->num_ceqs) - return -EINVAL; - - eq = &dev->ceqs->ceq[q_id]; - *page_phy_addr = eq->eq_pages[page_idx].align_paddr; - sdk_info(dev->dev_hdl, "ceq_page_phy_addr: 0x%llx page_idx=%u\n", - eq->eq_pages[page_idx].align_paddr, page_idx); - - return 0; -} - -int sphw_set_ceq_irq_disable(void *hwdev, u16 q_id) -{ - struct sphw_hwdev *dev = hwdev; - struct sphw_eq *ceq = NULL; - - if (!hwdev) - return -EINVAL; - - if (q_id >= dev->ceqs->num_ceqs) - return -EINVAL; - - ceq = &dev->ceqs->ceq[q_id]; - - sphw_set_msix_state(ceq->hwdev, ceq->eq_irq.msix_entry_idx, SPHW_MSIX_DISABLE); - - return 0; -} diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwif.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwif.c index 7230ce2f0778..fbb1128957f0 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwif.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwif.c @@ -338,32 +338,6 @@ void sphw_disable_doorbell(struct sphw_hwif *hwif) sphw_hwif_write_reg(hwif, addr, attr4); }
-void sphw_enable_outbound(struct sphw_hwif *hwif) -{ - u32 addr, attr5; - - addr = SPHW_CSR_FUNC_ATTR5_ADDR; - attr5 = sphw_hwif_read_reg(hwif, addr); - - attr5 = SPHW_AF5_CLEAR(attr5, OUTBOUND_CTRL); - attr5 |= SPHW_AF5_SET(ENABLE_OUTBOUND, OUTBOUND_CTRL); - - sphw_hwif_write_reg(hwif, addr, attr5); -} - -void sphw_disable_outbound(struct sphw_hwif *hwif) -{ - u32 addr, attr5; - - addr = SPHW_CSR_FUNC_ATTR5_ADDR; - attr5 = sphw_hwif_read_reg(hwif, addr); - - attr5 = SPHW_AF5_CLEAR(attr5, OUTBOUND_CTRL); - attr5 |= SPHW_AF5_SET(DISABLE_OUTBOUND, OUTBOUND_CTRL); - - sphw_hwif_write_reg(hwif, addr, attr5); -} - /** * set_ppf - try to set hwif as ppf and set the type of hwif in this case * @hwif: the hardware interface of a pci function device @@ -441,6 +415,7 @@ static int init_db_area_idx(struct sphw_free_db_area *free_db_area, u64 db_dwqe_ } free_db_area->db_max_areas = db_max_areas; spin_lock_init(&free_db_area->idx_lock); + return 0; }
diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c index edaef57a6b32..672882190907 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c @@ -1458,24 +1458,6 @@ int sphw_mbox_to_vf(void *hwdev, u16 vf_id, u8 mod, u16 cmd, void *buf_in, u16 i in_size, buf_out, out_size, timeout, channel); }
-int sphw_mbox_set_channel_status(struct sphw_hwdev *hwdev, u16 channel, bool enable) -{ - if (channel >= SPHW_CHANNEL_MAX) { - sdk_err(hwdev->dev_hdl, "Invalid channel id: 0x%x\n", channel); - return -EINVAL; - } - - if (enable) - clear_bit(channel, &hwdev->func_to_func->channel_stop); - else - set_bit(channel, &hwdev->func_to_func->channel_stop); - - sdk_info(hwdev->dev_hdl, "%s mbox channel 0x%x\n", - enable ? "Enable" : "Disable", channel); - - return 0; -} - void sphw_mbox_enable_channel_lock(struct sphw_hwdev *hwdev, bool enable) { hwdev->func_to_func->lock_channel_en = enable; diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.h b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.h index 1a7e0dff0965..9aebee1c088a 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.h +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.h @@ -266,8 +266,6 @@ int sphw_mbox_ppf_to_host(void *hwdev, u8 mod, u16 cmd, u8 host_id,
int sphw_mbox_init_host_msg_channel(struct sphw_hwdev *hwdev);
-int sphw_mbox_set_channel_status(struct sphw_hwdev *hwdev, u16 channel, bool enable); - void sphw_mbox_enable_channel_lock(struct sphw_hwdev *hwdev, bool enable);
#endif
Ramaxel inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4P01N CVE: NA
Delete all functions about clp hardware channels since the driver does not use clp hardware channel.
Signed-off-by: Yanling Song songyl@ramaxel.com Reviewed-by: Yang Gan yanggan@ramaxel.com --- .../net/ethernet/ramaxel/spnic/hw/sphw_csr.h | 13 - .../net/ethernet/ramaxel/spnic/hw/sphw_hw.h | 2 - .../ethernet/ramaxel/spnic/hw/sphw_hwdev.c | 30 -- .../ethernet/ramaxel/spnic/hw/sphw_hwdev.h | 1 - .../net/ethernet/ramaxel/spnic/hw/sphw_mgmt.c | 487 ------------------ .../net/ethernet/ramaxel/spnic/hw/sphw_mgmt.h | 50 -- .../net/ethernet/ramaxel/spnic/hw/sphw_mt.h | 1 - 7 files changed, 584 deletions(-)
diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_csr.h b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_csr.h index 3d84e1ef2fa3..d283c1456615 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_csr.h +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_csr.h @@ -39,19 +39,6 @@ (SPHW_CFG_REGS_FLAG + 0x0108) #define SPHW_FUNC_CSR_MAILBOX_RESULT_L_OFF \ (SPHW_CFG_REGS_FLAG + 0x010C) -/*CLP registers*/ -#define SPHW_BAR3_CLP_BASE_ADDR (SPHW_MGMT_REGS_FLAG + 0x0000) - -#define SPHW_UCPU_CLP_SIZE_REG (SPHW_HOST_CSR_BASE_ADDR + 0x40) -#define SPHW_UCPU_CLP_REQBASE_REG (SPHW_HOST_CSR_BASE_ADDR + 0x44) -#define SPHW_UCPU_CLP_RSPBASE_REG (SPHW_HOST_CSR_BASE_ADDR + 0x48) -#define SPHW_UCPU_CLP_REQ_REG (SPHW_HOST_CSR_BASE_ADDR + 0x4c) -#define SPHW_UCPU_CLP_RSP_REG (SPHW_HOST_CSR_BASE_ADDR + 0x50) -#define SPHW_CLP_REG(member) (SPHW_UCPU_CLP_##member##_REG) - -#define SPHW_CLP_REQ_DATA SPHW_BAR3_CLP_BASE_ADDR -#define SPHW_CLP_RSP_DATA (SPHW_BAR3_CLP_BASE_ADDR + 0x1000) -#define SPHW_CLP_DATA(member) (SPHW_CLP_##member##_DATA)
#define SPHW_PPF_ELECTION_OFFSET 0x0 #define SPHW_MPF_ELECTION_OFFSET 0x20 diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hw.h b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hw.h index 74607ff24f09..41945efe86d8 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hw.h +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hw.h @@ -482,8 +482,6 @@ int sphw_mbox_to_pf(void *hwdev, u8 mod, u16 cmd, void *buf_in, u16 in_size, voi int sphw_mbox_to_vf(void *hwdev, u16 vf_id, u8 mod, u16 cmd, void *buf_in, u16 in_size, void *buf_out, u16 *out_size, u32 timeout, u16 channel);
-int sphw_clp_to_mgmt(void *hwdev, u8 mod, u16 cmd, const void *buf_in, - u16 in_size, void *buf_out, u16 *out_size); /** * @brief sphw_cmdq_async - cmdq asynchronous message * @param hwdev: device pointer to hwdev diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c index fc7d101a7fe3..8eda93a5c5bd 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c @@ -455,28 +455,6 @@ static int init_ceqs_msix_attr(struct sphw_hwdev *hwdev) return 0; }
-static int sphw_comm_clp_to_mgmt_init(struct sphw_hwdev *hwdev) -{ - int err; - - if (sphw_func_type(hwdev) == TYPE_VF) - return 0; - - err = sphw_clp_pf_to_mgmt_init(hwdev); - if (err) - return err; - - return 0; -} - -static void sphw_comm_clp_to_mgmt_free(struct sphw_hwdev *hwdev) -{ - if (sphw_func_type(hwdev) == TYPE_VF) - return; - - sphw_clp_pf_to_mgmt_free(hwdev); -} - static int sphw_comm_aeqs_init(struct sphw_hwdev *hwdev) { struct irq_info aeq_irqs[SPHW_MAX_AEQS] = {{0} }; @@ -777,15 +755,8 @@ static int init_pf_mgmt_channel(struct sphw_hwdev *hwdev) { int err;
- err = sphw_comm_clp_to_mgmt_init(hwdev); - if (err) { - sdk_err(hwdev->dev_hdl, "Failed to init clp\n"); - return err; - } - err = sphw_comm_pf_to_mgmt_init(hwdev); if (err) { - sphw_comm_clp_to_mgmt_free(hwdev); sdk_err(hwdev->dev_hdl, "Failed to init pf to mgmt\n"); return err; } @@ -795,7 +766,6 @@ static int init_pf_mgmt_channel(struct sphw_hwdev *hwdev)
static void free_pf_mgmt_channel(struct sphw_hwdev *hwdev) { - sphw_comm_clp_to_mgmt_free(hwdev); sphw_comm_pf_to_mgmt_free(hwdev); }
diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.h b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.h index bf0b93d9a4d2..83f9a6630c8b 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.h +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.h @@ -55,7 +55,6 @@ struct sphw_hwdev { struct sphw_ceqs *ceqs; struct sphw_mbox *func_to_func; struct sphw_msg_pf_to_mgmt *pf_to_mgmt; - struct sphw_clp_pf_to_mgmt *clp_pf_to_mgmt;
void *cqm_hdl; struct mqm_addr_trans_tbl_info mqm_att; diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mgmt.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mgmt.c index f885ca8ce761..01e88535a0ab 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mgmt.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mgmt.c @@ -174,28 +174,6 @@ static void prepare_header(struct sphw_msg_pf_to_mgmt *pf_to_mgmt, SPHW_MSG_HEADER_SET(msg_id, MSG_ID); }
-static void clp_prepare_header(struct sphw_hwdev *hwdev, u64 *header, - u16 msg_len, u8 mod, - enum sphw_msg_ack_type ack_type, - enum sphw_msg_direction_type direction, - enum sphw_mgmt_cmd cmd, u32 msg_id) -{ - struct sphw_hwif *hwif = hwdev->hwif; - - *header = SPHW_MSG_HEADER_SET(msg_len, MSG_LEN) | - SPHW_MSG_HEADER_SET(mod, MODULE) | - SPHW_MSG_HEADER_SET(msg_len, SEG_LEN) | - SPHW_MSG_HEADER_SET(ack_type, NO_ACK) | - SPHW_MSG_HEADER_SET(SPHW_DATA_INLINE, DATA_TYPE) | - SPHW_MSG_HEADER_SET(0, SEQID) | - SPHW_MSG_HEADER_SET(SPHW_API_CHAIN_AEQ_ID, AEQ_ID) | - SPHW_MSG_HEADER_SET(LAST_SEGMENT, LAST) | - SPHW_MSG_HEADER_SET(direction, DIRECTION) | - SPHW_MSG_HEADER_SET(cmd, CMD) | - SPHW_MSG_HEADER_SET(hwif->attr.func_global_idx, SRC_GLB_FUNC_IDX) | - SPHW_MSG_HEADER_SET(msg_id, MSG_ID); -} - /** * prepare_mgmt_cmd - prepare the mgmt command * @mgmt_cmd: pointer to the command to prepare @@ -515,8 +493,6 @@ static void mgmt_recv_msg_handler(struct sphw_msg_pf_to_mgmt *pf_to_mgmt, goto resp; }
- /* TO DO some message need to ack first*/ - pf_to_mgmt->recv_mgmt_msg_cb[tmp_mod](pf_to_mgmt->hwdev, pf_to_mgmt->recv_mgmt_msg_data[tmp_mod], cmd, buf_in, in_size, buf_out, &out_size); @@ -917,466 +893,3 @@ int sphw_api_cmd_write_nack(void *hwdev, u8 dest, const void *cmd, u16 size)
return sphw_api_cmd_write(chain, dest, cmd, size); } - -static int get_clp_reg(void *hwdev, enum clp_data_type data_type, - enum clp_reg_type reg_type, u32 *reg_addr) -{ - struct sphw_hwdev *dev = hwdev; - u32 offset; - - offset = SPHW_CLP_REG_GAP * sphw_pcie_itf_id(dev); - - switch (reg_type) { - case SPHW_CLP_BA_HOST: - *reg_addr = (data_type == SPHW_CLP_REQ_HOST) ? - SPHW_CLP_REG(REQBASE) : - SPHW_CLP_REG(RSPBASE); - break; - - case SPHW_CLP_SIZE_HOST: - *reg_addr = SPHW_CLP_REG(SIZE); - break; - - case SPHW_CLP_LEN_HOST: - *reg_addr = (data_type == SPHW_CLP_REQ_HOST) ? - SPHW_CLP_REG(REQ) : SPHW_CLP_REG(RSP); - break; - - case SPHW_CLP_START_REQ_HOST: - *reg_addr = SPHW_CLP_REG(REQ); - break; - - case SPHW_CLP_READY_RSP_HOST: - *reg_addr = SPHW_CLP_REG(RSP); - break; - - default: - *reg_addr = 0; - break; - } - if (*reg_addr == 0) - return -EINVAL; - - *reg_addr += offset; - - return 0; -} - -static inline int clp_param_valid(struct sphw_hwdev *hwdev, - enum clp_data_type data_type, - enum clp_reg_type reg_type) -{ - if (data_type == SPHW_CLP_REQ_HOST && - reg_type == SPHW_CLP_READY_RSP_HOST) - return -EINVAL; - - if (data_type == SPHW_CLP_RSP_HOST && - reg_type == SPHW_CLP_START_REQ_HOST) - return -EINVAL; - - return 0; -} - -static u32 get_clp_reg_value(struct sphw_hwdev *hwdev, - enum clp_data_type data_type, - enum clp_reg_type reg_type, u32 reg_addr) -{ - u32 value; - - value = sphw_hwif_read_reg(hwdev->hwif, reg_addr); - - switch (reg_type) { - case SPHW_CLP_BA_HOST: - value = ((value >> SPHW_CLP_OFFSET(BASE)) & - SPHW_CLP_MASK(BASE)); - break; - - case SPHW_CLP_SIZE_HOST: - if (data_type == SPHW_CLP_REQ_HOST) - value = ((value >> SPHW_CLP_OFFSET(REQ_SIZE)) & - SPHW_CLP_MASK(SIZE)); - else - value = ((value >> SPHW_CLP_OFFSET(RSP_SIZE)) & - SPHW_CLP_MASK(SIZE)); - break; - - case SPHW_CLP_LEN_HOST: - value = ((value >> SPHW_CLP_OFFSET(LEN)) & - SPHW_CLP_MASK(LEN)); - break; - - case SPHW_CLP_START_REQ_HOST: - value = ((value >> SPHW_CLP_OFFSET(START)) & - SPHW_CLP_MASK(START)); - break; - - case SPHW_CLP_READY_RSP_HOST: - value = ((value >> SPHW_CLP_OFFSET(READY)) & - SPHW_CLP_MASK(READY)); - break; - - default: - break; - } - - return value; -} - -static int sphw_read_clp_reg(struct sphw_hwdev *hwdev, enum clp_data_type data_type, - enum clp_reg_type reg_type, u32 *read_value) -{ - u32 reg_addr; - int err; - - err = clp_param_valid(hwdev, data_type, reg_type); - if (err) - return err; - - err = get_clp_reg(hwdev, data_type, reg_type, ®_addr); - if (err) - return err; - - *read_value = get_clp_reg_value(hwdev, data_type, reg_type, reg_addr); - - return 0; -} - -static int check_data_type(enum clp_data_type data_type, enum clp_reg_type reg_type) -{ - if (data_type == SPHW_CLP_REQ_HOST && - reg_type == SPHW_CLP_READY_RSP_HOST) - return -EINVAL; - if (data_type == SPHW_CLP_RSP_HOST && - reg_type == SPHW_CLP_START_REQ_HOST) - return -EINVAL; - - return 0; -} - -static int check_reg_value(enum clp_reg_type reg_type, u32 value) -{ - if (reg_type == SPHW_CLP_BA_HOST && - value > SPHW_CLP_SRAM_BASE_REG_MAX) - return -EINVAL; - - if (reg_type == SPHW_CLP_SIZE_HOST && - value > SPHW_CLP_SRAM_SIZE_REG_MAX) - return -EINVAL; - - if (reg_type == SPHW_CLP_LEN_HOST && - value > SPHW_CLP_LEN_REG_MAX) - return -EINVAL; - - if ((reg_type == SPHW_CLP_START_REQ_HOST || - reg_type == SPHW_CLP_READY_RSP_HOST) && - value > SPHW_CLP_START_OR_READY_REG_MAX) - return -EINVAL; - - return 0; -} - -static int sphw_check_clp_init_status(struct sphw_hwdev *hwdev) -{ - int err; - u32 reg_value = 0; - - err = sphw_read_clp_reg(hwdev, SPHW_CLP_REQ_HOST, SPHW_CLP_BA_HOST, ®_value); - if (err || !reg_value) { - sdk_err(hwdev->dev_hdl, "Wrong req ba value: 0x%x\n", - reg_value); - return -EINVAL; - } - - err = sphw_read_clp_reg(hwdev, SPHW_CLP_RSP_HOST, SPHW_CLP_BA_HOST, ®_value); - if (err || !reg_value) { - sdk_err(hwdev->dev_hdl, "Wrong rsp ba value: 0x%x\n", - reg_value); - return -EINVAL; - } - - err = sphw_read_clp_reg(hwdev, SPHW_CLP_REQ_HOST, SPHW_CLP_SIZE_HOST, ®_value); - if (err || !reg_value) { - sdk_err(hwdev->dev_hdl, "Wrong req size\n"); - return -EINVAL; - } - - err = sphw_read_clp_reg(hwdev, SPHW_CLP_RSP_HOST, SPHW_CLP_SIZE_HOST, ®_value); - if (err || !reg_value) { - sdk_err(hwdev->dev_hdl, "Wrong rsp size\n"); - return -EINVAL; - } - - return 0; -} - -static void sphw_write_clp_reg(struct sphw_hwdev *hwdev, enum clp_data_type data_type, - enum clp_reg_type reg_type, u32 value) -{ - u32 reg_addr, reg_value; - - if (check_data_type(data_type, reg_type)) - return; - - if (check_reg_value(reg_type, value)) - return; - - if (get_clp_reg(hwdev, data_type, reg_type, ®_addr)) - return; - - reg_value = sphw_hwif_read_reg(hwdev->hwif, reg_addr); - - switch (reg_type) { - case SPHW_CLP_LEN_HOST: - reg_value = reg_value & - (~(SPHW_CLP_MASK(LEN) << SPHW_CLP_OFFSET(LEN))); - reg_value = reg_value | (value << SPHW_CLP_OFFSET(LEN)); - break; - - case SPHW_CLP_START_REQ_HOST: - reg_value = reg_value & - (~(SPHW_CLP_MASK(START) << - SPHW_CLP_OFFSET(START))); - reg_value = reg_value | (value << SPHW_CLP_OFFSET(START)); - break; - - case SPHW_CLP_READY_RSP_HOST: - reg_value = reg_value & - (~(SPHW_CLP_MASK(READY) << - SPHW_CLP_OFFSET(READY))); - reg_value = reg_value | (value << SPHW_CLP_OFFSET(READY)); - break; - - default: - return; - } - - sphw_hwif_write_reg(hwdev->hwif, reg_addr, reg_value); -} - -static int sphw_read_clp_data(struct sphw_hwdev *hwdev, void *buf_out, u16 *out_size) -{ - int err; - u32 reg = SPHW_CLP_DATA(RSP); - u32 ready, delay_cnt; - u32 *ptr = (u32 *)buf_out; - u32 temp_out_size = 0; - - err = sphw_read_clp_reg(hwdev, SPHW_CLP_RSP_HOST, SPHW_CLP_READY_RSP_HOST, &ready); - if (err) - return err; - - delay_cnt = 0; - while (ready == 0) { - usleep_range(9000, 10000); - delay_cnt++; - err = sphw_read_clp_reg(hwdev, SPHW_CLP_RSP_HOST, SPHW_CLP_READY_RSP_HOST, &ready); - if (err || delay_cnt > SPHW_CLP_DELAY_CNT_MAX) { - sdk_err(hwdev->dev_hdl, "Timeout with delay_cnt: %u\n", - delay_cnt); - return -EINVAL; - } - } - - err = sphw_read_clp_reg(hwdev, SPHW_CLP_RSP_HOST, SPHW_CLP_LEN_HOST, &temp_out_size); - if (err) - return err; - - if (temp_out_size > SPHW_CLP_SRAM_SIZE_REG_MAX || !temp_out_size) { - sdk_err(hwdev->dev_hdl, "Invalid temp_out_size: %u\n", - temp_out_size); - return -EINVAL; - } - - *out_size = (u16)temp_out_size; - for (; temp_out_size > 0; temp_out_size--) { - *ptr = sphw_hwif_read_reg(hwdev->hwif, reg); - ptr++; - /* read 4 bytes every time */ - reg = reg + 4; - } - - sphw_write_clp_reg(hwdev, SPHW_CLP_RSP_HOST, SPHW_CLP_READY_RSP_HOST, (u32)0x0); - sphw_write_clp_reg(hwdev, SPHW_CLP_RSP_HOST, SPHW_CLP_LEN_HOST, (u32)0x0); - - return 0; -} - -static int sphw_write_clp_data(struct sphw_hwdev *hwdev, void *buf_in, u16 in_size) -{ - int err; - u32 reg = SPHW_CLP_DATA(REQ); - u32 start = 1; - u32 delay_cnt = 0; - u32 *ptr = (u32 *)buf_in; - - err = sphw_read_clp_reg(hwdev, SPHW_CLP_REQ_HOST, SPHW_CLP_START_REQ_HOST, &start); - if (err) - return err; - - while (start == 1) { - usleep_range(9000, 10000); - delay_cnt++; - err = sphw_read_clp_reg(hwdev, SPHW_CLP_REQ_HOST, SPHW_CLP_START_REQ_HOST, &start); - if (err || delay_cnt > SPHW_CLP_DELAY_CNT_MAX) - return -EINVAL; - } - - sphw_write_clp_reg(hwdev, SPHW_CLP_REQ_HOST, SPHW_CLP_LEN_HOST, in_size); - sphw_write_clp_reg(hwdev, SPHW_CLP_REQ_HOST, SPHW_CLP_START_REQ_HOST, (u32)0x1); - - for (; in_size > 0; in_size--) { - sphw_hwif_write_reg(hwdev->hwif, reg, *ptr); - ptr++; - reg = reg + 4; - } - - return 0; -} - -static void sphw_clear_clp_data(struct sphw_hwdev *hwdev, enum clp_data_type data_type) -{ - u32 reg = (data_type == SPHW_CLP_REQ_HOST) ? - SPHW_CLP_DATA(REQ) : SPHW_CLP_DATA(RSP); - u32 count = SPHW_CLP_INPUT_BUF_LEN_HOST / SPHW_CLP_DATA_UNIT_HOST; - - for (; count > 0; count--) { - sphw_hwif_write_reg(hwdev->hwif, reg, 0x0); - reg = reg + 4; - } -} - -int sphw_pf_clp_to_mgmt(void *hwdev, u8 mod, u16 cmd, const void *buf_in, - u16 in_size, void *buf_out, u16 *out_size) -{ - struct sphw_clp_pf_to_mgmt *clp_pf_to_mgmt; - struct sphw_hwdev *dev = hwdev; - u64 header; - u16 real_size; - u8 *clp_msg_buf; - int err; - - clp_pf_to_mgmt = ((struct sphw_hwdev *)hwdev)->clp_pf_to_mgmt; - clp_msg_buf = clp_pf_to_mgmt->clp_msg_buf; - - /* 4 bytes alignment */ - if (in_size % SPHW_CLP_DATA_UNIT_HOST) - real_size = (in_size + (u16)sizeof(header) + SPHW_CLP_DATA_UNIT_HOST); - else - real_size = in_size + (u16)sizeof(header); - real_size = real_size / SPHW_CLP_DATA_UNIT_HOST; - - if (real_size > (SPHW_CLP_INPUT_BUF_LEN_HOST / SPHW_CLP_DATA_UNIT_HOST)) { - sdk_err(dev->dev_hdl, "Invalid real_size: %u\n", real_size); - return -EINVAL; - } - down(&clp_pf_to_mgmt->clp_msg_lock); - - err = sphw_check_clp_init_status(dev); - if (err) { - sdk_err(dev->dev_hdl, "Check clp init status failed\n"); - up(&clp_pf_to_mgmt->clp_msg_lock); - return err; - } - - sphw_clear_clp_data(dev, SPHW_CLP_RSP_HOST); - sphw_write_clp_reg(dev, SPHW_CLP_RSP_HOST, SPHW_CLP_READY_RSP_HOST, 0x0); - - /* Send request */ - memset(clp_msg_buf, 0x0, SPHW_CLP_INPUT_BUF_LEN_HOST); - clp_prepare_header(dev, &header, in_size, mod, 0, 0, cmd, 0); - - memcpy(clp_msg_buf, &header, sizeof(header)); - clp_msg_buf += sizeof(header); - memcpy(clp_msg_buf, buf_in, in_size); - - clp_msg_buf = clp_pf_to_mgmt->clp_msg_buf; - - sphw_clear_clp_data(dev, SPHW_CLP_REQ_HOST); - err = sphw_write_clp_data(hwdev, clp_pf_to_mgmt->clp_msg_buf, real_size); - if (err) { - sdk_err(dev->dev_hdl, "Send clp request failed\n"); - up(&clp_pf_to_mgmt->clp_msg_lock); - return -EINVAL; - } - - /* Get response */ - clp_msg_buf = clp_pf_to_mgmt->clp_msg_buf; - memset(clp_msg_buf, 0x0, SPHW_CLP_INPUT_BUF_LEN_HOST); - err = sphw_read_clp_data(hwdev, clp_msg_buf, &real_size); - sphw_clear_clp_data(dev, SPHW_CLP_RSP_HOST); - if (err) { - sdk_err(dev->dev_hdl, "Read clp response failed\n"); - up(&clp_pf_to_mgmt->clp_msg_lock); - return -EINVAL; - } - - real_size = (u16)((real_size * SPHW_CLP_DATA_UNIT_HOST) & 0xffff); - if (real_size <= sizeof(header) || real_size > SPHW_CLP_INPUT_BUF_LEN_HOST) { - sdk_err(dev->dev_hdl, "Invalid response size: %u", real_size); - up(&clp_pf_to_mgmt->clp_msg_lock); - return -EINVAL; - } - real_size = real_size - sizeof(header); - if (real_size != *out_size) { - sdk_err(dev->dev_hdl, "Invalid real_size:%u, out_size: %u\n", - real_size, *out_size); - up(&clp_pf_to_mgmt->clp_msg_lock); - return -EINVAL; - } - - memcpy(buf_out, (clp_msg_buf + sizeof(header)), real_size); - up(&clp_pf_to_mgmt->clp_msg_lock); - - return 0; -} - -int sphw_clp_to_mgmt(void *hwdev, u8 mod, u16 cmd, const void *buf_in, - u16 in_size, void *buf_out, u16 *out_size) - -{ - struct sphw_hwdev *dev = hwdev; - int err; - - if (!dev) - return -EINVAL; - - if (!dev->chip_present_flag) - return -EPERM; - - if (sphw_func_type(hwdev) == TYPE_VF) - return -EINVAL; - - err = sphw_pf_clp_to_mgmt(dev, mod, cmd, buf_in, in_size, buf_out, - out_size); - - return err; -} - -int sphw_clp_pf_to_mgmt_init(struct sphw_hwdev *hwdev) -{ - struct sphw_clp_pf_to_mgmt *clp_pf_to_mgmt; - - clp_pf_to_mgmt = kzalloc(sizeof(*clp_pf_to_mgmt), GFP_KERNEL); - if (!clp_pf_to_mgmt) - return -ENOMEM; - - clp_pf_to_mgmt->clp_msg_buf = kzalloc(SPHW_CLP_INPUT_BUF_LEN_HOST, - GFP_KERNEL); - if (!clp_pf_to_mgmt->clp_msg_buf) { - kfree(clp_pf_to_mgmt); - return -ENOMEM; - } - sema_init(&clp_pf_to_mgmt->clp_msg_lock, 1); - - hwdev->clp_pf_to_mgmt = clp_pf_to_mgmt; - - return 0; -} - -void sphw_clp_pf_to_mgmt_free(struct sphw_hwdev *hwdev) -{ - struct sphw_clp_pf_to_mgmt *clp_pf_to_mgmt = hwdev->clp_pf_to_mgmt; - - kfree(clp_pf_to_mgmt->clp_msg_buf); - kfree(clp_pf_to_mgmt); -} diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mgmt.h b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mgmt.h index c6f63f935ea5..802336bd5cb1 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mgmt.h +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mgmt.h @@ -6,44 +6,6 @@
#define SPHW_MGMT_WQ_NAME "sphw_mgmt"
-#define SPHW_CLP_REG_GAP 0x20 -#define SPHW_CLP_INPUT_BUF_LEN_HOST 4096UL -#define SPHW_CLP_DATA_UNIT_HOST 4UL - -enum clp_data_type { - SPHW_CLP_REQ_HOST = 0, - SPHW_CLP_RSP_HOST = 1 -}; - -enum clp_reg_type { - SPHW_CLP_BA_HOST = 0, - SPHW_CLP_SIZE_HOST = 1, - SPHW_CLP_LEN_HOST = 2, - SPHW_CLP_START_REQ_HOST = 3, - SPHW_CLP_READY_RSP_HOST = 4 -}; - -#define SPHW_CLP_REQ_SIZE_OFFSET 0 -#define SPHW_CLP_RSP_SIZE_OFFSET 16 -#define SPHW_CLP_BASE_OFFSET 0 -#define SPHW_CLP_LEN_OFFSET 0 -#define SPHW_CLP_START_OFFSET 31 -#define SPHW_CLP_READY_OFFSET 31 -#define SPHW_CLP_OFFSET(member) (SPHW_CLP_##member##_OFFSET) - -#define SPHW_CLP_SIZE_MASK 0x7ffUL -#define SPHW_CLP_BASE_MASK 0x7ffffffUL -#define SPHW_CLP_LEN_MASK 0x7ffUL -#define SPHW_CLP_START_MASK 0x1UL -#define SPHW_CLP_READY_MASK 0x1UL -#define SPHW_CLP_MASK(member) (SPHW_CLP_##member##_MASK) - -#define SPHW_CLP_DELAY_CNT_MAX 200UL -#define SPHW_CLP_SRAM_SIZE_REG_MAX 0x3ff -#define SPHW_CLP_SRAM_BASE_REG_MAX 0x7ffffff -#define SPHW_CLP_LEN_REG_MAX 0x3ff -#define SPHW_CLP_START_OR_READY_REG_MAX 0x1 - struct sphw_recv_msg { void *msg;
@@ -78,11 +40,6 @@ enum sphw_mgmt_msg_cb_state { SPHW_MGMT_MSG_CB_RUNNING, };
-struct sphw_clp_pf_to_mgmt { - struct semaphore clp_msg_lock; - void *clp_msg_buf; -}; - struct sphw_msg_pf_to_mgmt { struct sphw_hwdev *hwdev;
@@ -146,11 +103,4 @@ int sphw_api_cmd_read_ack(void *hwdev, u8 dest, const void *cmd, u16 size,
int sphw_api_cmd_write_nack(void *hwdev, u8 dest, const void *cmd, u16 size);
-int sphw_pf_clp_to_mgmt(void *hwdev, u8 mod, u16 cmd, const void *buf_in, - u16 in_size, void *buf_out, u16 *out_size); - -int sphw_clp_pf_to_mgmt_init(struct sphw_hwdev *hwdev); - -void sphw_clp_pf_to_mgmt_free(struct sphw_hwdev *hwdev); - #endif diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mt.h b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mt.h index 1960614b384b..d7fb58054202 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mt.h +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mt.h @@ -461,7 +461,6 @@ enum mt_api_type { API_TYPE_MBOX = 1, API_TYPE_API_CHAIN_BYPASS, API_TYPE_API_CHAIN_TO_MPU, - API_TYPE_CLP, };
struct npu_cmd_st {
Ramaxel inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4P01N CVE: NA
Remove the code of polling mode since the driver only use interrupt mode and not use poll mode.
Signed-off-by: Yanling Song songyl@ramaxel.com Reviewed-by: Yang Gan yanggan@ramaxel.com --- .../net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c | 20 ++++--------------- .../net/ethernet/ramaxel/spnic/hw/sphw_crm.h | 2 -- .../net/ethernet/ramaxel/spnic/hw/sphw_eqs.c | 7 +------ .../ethernet/ramaxel/spnic/hw/sphw_hwdev.c | 1 - .../ethernet/ramaxel/spnic/hw/sphw_hwdev.h | 1 - .../net/ethernet/ramaxel/spnic/hw/sphw_mbox.c | 2 +- 6 files changed, 6 insertions(+), 27 deletions(-)
diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c index 9cc44f15fa0e..b6aaadac19b9 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c @@ -533,22 +533,10 @@ static int cmdq_ceq_handler_status(struct sphw_cmdq *cmdq, { ulong timeo; int err; - ulong start = 0; - ulong end = timeout; - - if (cmdq->hwdev->poll) { - while (start < end) { - sphw_cmdq_ceq_handler(cmdq->hwdev, 0); - if (saved_cmd_info->done->done != 0) - return 0; - usleep_range(900, 1000); - start++; - } - } else { - timeo = msecs_to_jiffies(timeout); - if (wait_for_completion_timeout(saved_cmd_info->done, timeo)) - return 0; - } + + timeo = msecs_to_jiffies(timeout); + if (wait_for_completion_timeout(saved_cmd_info->done, timeo)) + return 0;
spin_lock_bh(&cmdq->cmdq_lock);
diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_crm.h b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_crm.h index bba3d2d501f2..8cce36698e3d 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_crm.h +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_crm.h @@ -335,8 +335,6 @@ struct sphw_init_para { * need to trasmit message ppf mbox to bmgw arm host. */ void *ppf_hwdev; - /* if use polling mode, set it true */ - bool poll; };
/* B200 config BAR45 4MB, DB & DWQE both 2MB */ diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_eqs.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_eqs.c index 8f71d9de76c1..24c55d656f9c 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_eqs.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_eqs.c @@ -392,12 +392,7 @@ static void set_eq_cons_idx(struct sphw_eq *eq, u32 arm_state) u32 addr = EQ_CI_SIMPLE_INDIR_REG_ADDR(eq);
eq_wrap_ci = EQ_CONS_IDX(eq); - - /* if use poll mode only eq0 use int_arm mode */ - if (eq->q_id != 0 && eq->hwdev->poll) - val = EQ_CI_SIMPLE_INDIR_SET(SPHW_EQ_NOT_ARMED, ARMED); - else - val = EQ_CI_SIMPLE_INDIR_SET(arm_state, ARMED); + val = EQ_CI_SIMPLE_INDIR_SET(arm_state, ARMED); if (eq->type == SPHW_AEQ) { val = val | EQ_CI_SIMPLE_INDIR_SET(eq_wrap_ci, CI) | diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c index 8eda93a5c5bd..783fa46bcfe5 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c @@ -938,7 +938,6 @@ int sphw_init_hwdev(struct sphw_init_para *para) hwdev->pcidev_hdl = para->pcidev_hdl; hwdev->dev_hdl = para->dev_hdl; hwdev->chip_node = para->chip_node; - hwdev->poll = para->poll;
hwdev->chip_fault_stats = vzalloc(SPHW_CHIP_FAULT_SIZE); if (!hwdev->chip_fault_stats) diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.h b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.h index 83f9a6630c8b..10da31bda3d2 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.h +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.h @@ -42,7 +42,6 @@ struct sphw_hwdev {
u32 wq_page_size; int chip_present_flag; - bool poll; /*use polling mode or int mode*/
struct sphw_hwif *hwif; /* include void __iomem *bar */ struct comm_global_attr glb_attr; diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c index 672882190907..8abb47422bdd 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_mbox.c @@ -1062,7 +1062,7 @@ static int send_mbox_msg(struct sphw_mbox *func_to_func, u8 mod, u16 cmd, u8 *msg_seg = NULL; u64 header = 0;
- if (hwdev->poll || hwdev->hwif->attr.num_aeqs >= 2) + if (hwdev->hwif->attr.num_aeqs >= 2) rsp_aeq_id = SPHW_MBOX_RSP_MSG_AEQ; else rsp_aeq_id = 0;
Ramaxel inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4P01N CVE: NA
Remove the code of endian converting since hardware converts endian automatically.
Signed-off-by: Yanling Song songyl@ramaxel.com Reviewed-by: Yang Gan yanggan@ramaxel.com --- .../net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c | 38 +++++------------- .../ethernet/ramaxel/spnic/hw/sphw_common.h | 12 ------ .../net/ethernet/ramaxel/spnic/spnic_nic_io.h | 6 +-- .../net/ethernet/ramaxel/spnic/spnic_nic_qp.h | 7 +--- drivers/net/ethernet/ramaxel/spnic/spnic_rx.c | 39 +++++++------------ drivers/net/ethernet/ramaxel/spnic/spnic_tx.c | 20 +++++----- 6 files changed, 34 insertions(+), 88 deletions(-)
diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c index b6aaadac19b9..5421b813d484 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_cmdq.c @@ -343,10 +343,6 @@ static void cmdq_set_db(struct sphw_cmdq *cmdq,
cmdq_fill_db(&db, cmdq_type, prod_idx);
- /* The data that is written to HW should be in Big Endian Format */ - db.db_info = sphw_hw_be32(db.db_info); - db.db_head = sphw_hw_be32(db.db_head); - wmb(); /* write all before the doorbell */ writeq(*((u64 *)&db), CMDQ_DB_ADDR(cmdq->db_base, prod_idx)); } @@ -482,24 +478,21 @@ static void cmdq_update_cmd_status(struct sphw_cmdq *cmdq, u16 prod_idx, cmd_info = &cmdq->cmd_infos[prod_idx];
if (cmd_info->errcode) { - status_info = sphw_hw_cpu32(wqe_lcmd->status.status_info); + status_info = wqe_lcmd->status.status_info; *cmd_info->errcode = WQE_ERRCODE_GET(status_info, VAL); }
if (cmd_info->direct_resp) - *cmd_info->direct_resp = - sphw_hw_cpu32(wqe_lcmd->completion.direct_resp); + *cmd_info->direct_resp = wqe_lcmd->completion.direct_resp; }
static int sphw_cmdq_sync_timeout_check(struct sphw_cmdq *cmdq, struct sphw_cmdq_wqe *wqe, u16 pi) { struct sphw_cmdq_wqe_lcmd *wqe_lcmd; - struct sphw_ctrl *ctrl; u32 ctrl_info;
wqe_lcmd = &wqe->wqe_lcmd; - ctrl = &wqe_lcmd->ctrl; - ctrl_info = sphw_hw_cpu32((ctrl)->ctrl_info); + ctrl_info = wqe_lcmd->ctrl.ctrl_info; if (!WQE_COMPLETED(ctrl_info)) { sdk_info(cmdq->hwdev->dev_hdl, "Cmdq sync command check busy bit not set\n"); return -EFAULT; @@ -640,7 +633,7 @@ static int cmdq_sync_cmd_direct_resp(struct sphw_cmdq *cmdq, u8 mod, struct sphw_cmdq_cmd_info *cmd_info = NULL, saved_cmd_info; struct completion done; u16 curr_prod_idx, next_prod_idx; - int wrapped, errcode = 0, wqe_size = WQE_LCMD_SIZE; + int wrapped, errcode = 0; int cmpt_code = CMDQ_SEND_CMPT_CODE; u64 curr_msg_id; int err; @@ -682,9 +675,6 @@ static int cmdq_sync_cmd_direct_resp(struct sphw_cmdq *cmdq, u8 mod, cmdq_set_lcmd_wqe(&wqe, SYNC_CMD_DIRECT_RESP, buf_in, NULL, wrapped, mod, cmd, curr_prod_idx);
- /* The data that is written to HW should be in Big Endian Format */ - sphw_hw_be32_len(&wqe, wqe_size); - /* CMDQ WQE is not shadow, therefore wqe will be written to wq */ cmdq_wqe_fill(curr_wqe, &wqe);
@@ -726,7 +716,7 @@ static int cmdq_sync_cmd_detail_resp(struct sphw_cmdq *cmdq, u8 mod, u8 cmd, struct sphw_cmdq_cmd_info *cmd_info = NULL, saved_cmd_info; struct completion done; u16 curr_prod_idx, next_prod_idx; - int wrapped, errcode = 0, wqe_size = WQE_LCMD_SIZE; + int wrapped, errcode = 0; int cmpt_code = CMDQ_SEND_CMPT_CODE; u64 curr_msg_id; int err; @@ -768,8 +758,6 @@ static int cmdq_sync_cmd_detail_resp(struct sphw_cmdq *cmdq, u8 mod, u8 cmd, cmdq_set_lcmd_wqe(&wqe, SYNC_CMD_SGE_RESP, buf_in, buf_out, wrapped, mod, cmd, curr_prod_idx);
- sphw_hw_be32_len(&wqe, wqe_size); - cmdq_wqe_fill(curr_wqe, &wqe);
(cmd_info->cmdq_msg_id)++; @@ -805,7 +793,6 @@ static int cmdq_async_cmd(struct sphw_cmdq *cmdq, u8 mod, u8 cmd, { struct sphw_cmdq_cmd_info *cmd_info = NULL; struct sphw_wq *wq = &cmdq->wq; - int wqe_size = WQE_LCMD_SIZE; u16 curr_prod_idx, next_prod_idx; struct sphw_cmdq_wqe *curr_wqe = NULL, wqe; int wrapped, err; @@ -832,8 +819,6 @@ static int cmdq_async_cmd(struct sphw_cmdq *cmdq, u8 mod, u8 cmd, cmdq_set_lcmd_wqe(&wqe, ASYNC_CMD, buf_in, NULL, wrapped, mod, cmd, curr_prod_idx);
- /* The data that is written to HW should be in Big Endian Format */ - sphw_hw_be32_len(&wqe, wqe_size); cmdq_wqe_fill(curr_wqe, &wqe);
cmd_info = &cmdq->cmd_infos[curr_prod_idx]; @@ -858,7 +843,7 @@ int cmdq_set_arm_bit(struct sphw_cmdq *cmdq, const void *buf_in, struct sphw_wq *wq = &cmdq->wq; struct sphw_cmdq_wqe *curr_wqe = NULL, wqe; u16 curr_prod_idx, next_prod_idx; - int wrapped, wqe_size = WQE_SCMD_SIZE; + int wrapped;
/* Keep wrapped and doorbell index correct. bh - for tasklet(ceq) */ spin_lock_bh(&cmdq->cmdq_lock); @@ -883,9 +868,6 @@ int cmdq_set_arm_bit(struct sphw_cmdq *cmdq, const void *buf_in, wrapped, SPHW_MOD_COMM, CMDQ_SET_ARM_CMD, curr_prod_idx);
- /* The data that is written to HW should be in Big Endian Format */ - sphw_cpu_to_be32(&wqe, wqe_size); - /* cmdq wqe is not shadow, therefore wqe will be written to wq */ cmdq_wqe_fill(curr_wqe, &wqe);
@@ -1102,7 +1084,7 @@ static void clear_wqe_complete_bit(struct sphw_cmdq *cmdq, struct sphw_cmdq_wqe *wqe, u16 ci) { struct sphw_ctrl *ctrl = NULL; - u32 header_info = sphw_hw_cpu32(WQE_HEADER(wqe)->header_info); + u32 header_info = WQE_HEADER(wqe)->header_info; enum data_format df = CMDQ_WQE_HEADER_GET(header_info, DATA_FMT);
if (df == DATA_SGE) @@ -1157,7 +1139,7 @@ static int cmdq_arm_ceq_handler(struct sphw_cmdq *cmdq, struct sphw_cmdq_wqe *wqe, u16 ci) { struct sphw_ctrl *ctrl = &wqe->inline_wqe.wqe_scmd.ctrl; - u32 ctrl_info = sphw_hw_cpu32((ctrl)->ctrl_info); + u32 ctrl_info = ctrl->ctrl_info;
if (!WQE_COMPLETED(ctrl_info)) return -EBUSY; @@ -1188,7 +1170,6 @@ void sphw_cmdq_ceq_handler(void *handle, u32 ceqe_data) struct sphw_hwdev *hwdev = cmdqs->hwdev; struct sphw_cmdq_wqe *wqe = NULL; struct sphw_cmdq_wqe_lcmd *wqe_lcmd = NULL; - struct sphw_ctrl *ctrl = NULL; struct sphw_cmdq_cmd_info *cmd_info = NULL; u32 ctrl_info; u16 ci; @@ -1216,8 +1197,7 @@ void sphw_cmdq_ceq_handler(void *handle, u32 ceqe_data) default: /* only arm bit is using scmd wqe, the wqe is lcmd */ wqe_lcmd = &wqe->wqe_lcmd; - ctrl = &wqe_lcmd->ctrl; - ctrl_info = sphw_hw_cpu32((ctrl)->ctrl_info); + ctrl_info = wqe_lcmd->ctrl.ctrl_info;
if (!WQE_COMPLETED(ctrl_info)) return; diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_common.h b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_common.h index d6e2f183cc36..05327bd4bcfe 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_common.h +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_common.h @@ -93,18 +93,6 @@ static inline void sphw_set_sge(struct sphw_sge *sge, dma_addr_t addr, int len) sge->len = len; }
-#define sphw_hw_be32(val) (val) -#define sphw_hw_cpu32(val) (val) -#define sphw_hw_cpu16(val) (val) - -static inline void sphw_hw_be32_len(void *data, int len) -{ -} - -static inline void sphw_hw_cpu32_len(void *data, int len) -{ -} - #define sdk_err(dev, format, ...) dev_err(dev, "[COMM]" format, ##__VA_ARGS__) #define sdk_warn(dev, format, ...) dev_warn(dev, "[COMM]" format, ##__VA_ARGS__) #define sdk_notice(dev, format, ...) dev_notice(dev, "[COMM]" format, ##__VA_ARGS__) diff --git a/drivers/net/ethernet/ramaxel/spnic/spnic_nic_io.h b/drivers/net/ethernet/ramaxel/spnic/spnic_nic_io.h index ab1399d3e36c..e237ba33d82d 100644 --- a/drivers/net/ethernet/ramaxel/spnic/spnic_nic_io.h +++ b/drivers/net/ethernet/ramaxel/spnic/spnic_nic_io.h @@ -101,8 +101,7 @@ static inline u16 spnic_get_sq_local_pi(struct spnic_io_queue *sq) */ static inline u16 spnic_get_sq_hw_ci(struct spnic_io_queue *sq) { - return WQ_MASK_IDX(&sq->wq, - sphw_hw_cpu16(*(u16 *)sq->tx.cons_idx_addr)); + return WQ_MASK_IDX(&sq->wq, *(u16 *)sq->tx.cons_idx_addr); }
/* * @@ -281,9 +280,6 @@ static inline void spnic_write_db(struct spnic_io_queue *queue, int cos, u8 cfla db.db_info = DB_INFO_SET(SRC_TYPE, TYPE) | DB_INFO_SET(cflag, CFLAG) | DB_INFO_SET(cos, COS) | DB_INFO_SET(queue->q_id, QID); db.pi_hi = DB_PI_HIGH(pi); - /* Data should be written to HW in Big Endian Format */ - db.db_info = sphw_hw_be32(db.db_info); - db.pi_hi = sphw_hw_be32(db.pi_hi);
wmb(); /* Write all before the doorbell */
diff --git a/drivers/net/ethernet/ramaxel/spnic/spnic_nic_qp.h b/drivers/net/ethernet/ramaxel/spnic/spnic_nic_qp.h index 4c3f37e45a36..a8abdc1734d3 100644 --- a/drivers/net/ethernet/ramaxel/spnic/spnic_nic_qp.h +++ b/drivers/net/ethernet/ramaxel/spnic/spnic_nic_qp.h @@ -352,7 +352,7 @@ enum sq_wqe_tasksect_len_type {
static inline u32 spnic_get_pkt_len_for_super_cqe(struct spnic_rq_cqe *cqe, bool last) { - u32 pkt_len = sphw_hw_cpu32(cqe->pkt_info); + u32 pkt_len = cqe->pkt_info;
if (!last) return RQ_CQE_PKT_LEN_GET(pkt_len, FIRST_LEN); @@ -376,7 +376,6 @@ static inline void spnic_prepare_sq_ctrl(struct spnic_sq_wqe_combo *wqe_combo, SQ_CTRL_SET(wqe_combo->wqe_type, EXTENDED) | SQ_CTRL_SET(owner, OWNER);
- wqe_desc->ctrl_len = sphw_hw_be32(wqe_desc->ctrl_len); /* compact wqe queue_info will transfer to ucode */ wqe_desc->queue_info = 0; return; @@ -388,8 +387,6 @@ static inline void spnic_prepare_sq_ctrl(struct spnic_sq_wqe_combo *wqe_combo, SQ_CTRL_SET(wqe_combo->wqe_type, EXTENDED) | SQ_CTRL_SET(owner, OWNER);
- wqe_desc->ctrl_len = sphw_hw_be32(wqe_desc->ctrl_len); - wqe_desc->queue_info = queue_info; wqe_desc->queue_info |= SQ_CTRL_QUEUE_INFO_SET(1U, UC);
@@ -400,8 +397,6 @@ static inline void spnic_prepare_sq_ctrl(struct spnic_sq_wqe_combo *wqe_combo, wqe_desc->queue_info = SQ_CTRL_QUEUE_INFO_CLEAR(wqe_desc->queue_info, MSS); wqe_desc->queue_info |= SQ_CTRL_QUEUE_INFO_SET(TX_MSS_MIN, MSS); } - - wqe_desc->queue_info = sphw_hw_be32(wqe_desc->queue_info); }
/* * diff --git a/drivers/net/ethernet/ramaxel/spnic/spnic_rx.c b/drivers/net/ethernet/ramaxel/spnic/spnic_rx.c index e58da6771ff4..3ae2f15c727b 100644 --- a/drivers/net/ethernet/ramaxel/spnic/spnic_rx.c +++ b/drivers/net/ethernet/ramaxel/spnic/spnic_rx.c @@ -92,7 +92,6 @@ static u32 spnic_rx_fill_wqe(struct spnic_rxq *rxq) { struct net_device *netdev = rxq->netdev; struct spnic_nic_dev *nic_dev = netdev_priv(netdev); - int rq_wqe_len = rxq->rq->wq.wqebb_size; struct spnic_rq_wqe *rq_wqe = NULL; struct spnic_rx_info *rx_info = NULL; u32 i; @@ -113,7 +112,6 @@ static u32 spnic_rx_fill_wqe(struct spnic_rxq *rxq) rq_wqe->normal_wqe.cqe_lo_addr = lower_32_bits(rx_info->cqe_dma); }
- sphw_hw_be32_len(rq_wqe, rq_wqe_len); rx_info->rq_wqe = rq_wqe; }
@@ -179,17 +177,12 @@ static u32 stub_spnic_rx_fill_buffers(struct spnic_rxq *rxq) dma_addr = rx_info->buf_dma_addr;
if (rxq->rq->wqe_type == SPNIC_EXTEND_RQ_WQE) { - rq_wqe->extend_wqe.buf_desc.sge.hi_addr = - sphw_hw_be32(upper_32_bits(dma_addr)); - rq_wqe->extend_wqe.buf_desc.sge.lo_addr = - sphw_hw_be32(lower_32_bits(dma_addr)); - rq_wqe->extend_wqe.buf_desc.sge.len = - sphw_hw_be32(rx_info->skb_len); + rq_wqe->extend_wqe.buf_desc.sge.hi_addr = upper_32_bits(dma_addr); + rq_wqe->extend_wqe.buf_desc.sge.lo_addr = lower_32_bits(dma_addr); + rq_wqe->extend_wqe.buf_desc.sge.len = rx_info->skb_len; } else { - rq_wqe->normal_wqe.buf_hi_addr = - sphw_hw_be32(upper_32_bits(dma_addr)); - rq_wqe->normal_wqe.buf_lo_addr = - sphw_hw_be32(lower_32_bits(dma_addr)); + rq_wqe->normal_wqe.buf_hi_addr = upper_32_bits(dma_addr); + rq_wqe->normal_wqe.buf_lo_addr = lower_32_bits(dma_addr); } rxq->next_to_update = (rxq->next_to_update + 1) & rxq->q_mask; } @@ -236,15 +229,11 @@ static u32 spnic_rx_fill_buffers(struct spnic_rxq *rxq) rq_wqe = rx_info->rq_wqe;
if (rxq->rq->wqe_type == SPNIC_EXTEND_RQ_WQE) { - rq_wqe->extend_wqe.buf_desc.sge.hi_addr = - sphw_hw_be32(upper_32_bits(dma_addr)); - rq_wqe->extend_wqe.buf_desc.sge.lo_addr = - sphw_hw_be32(lower_32_bits(dma_addr)); + rq_wqe->extend_wqe.buf_desc.sge.hi_addr = upper_32_bits(dma_addr); + rq_wqe->extend_wqe.buf_desc.sge.lo_addr = lower_32_bits(dma_addr); } else { - rq_wqe->normal_wqe.buf_hi_addr = - sphw_hw_be32(upper_32_bits(dma_addr)); - rq_wqe->normal_wqe.buf_lo_addr = - sphw_hw_be32(lower_32_bits(dma_addr)); + rq_wqe->normal_wqe.buf_hi_addr = upper_32_bits(dma_addr); + rq_wqe->normal_wqe.buf_lo_addr = lower_32_bits(dma_addr); } rxq->next_to_update = (rxq->next_to_update + 1) & rxq->q_mask; } @@ -784,7 +773,7 @@ int recv_one_pkt(struct spnic_rxq *rxq, struct spnic_rq_cqe *rx_cqe, if (skb_is_nonlinear(skb)) spnic_pull_tail(skb);
- offload_type = sphw_hw_cpu32(rx_cqe->offload_type); + offload_type = rx_cqe->offload_type; spnic_rx_csum(rxq, offload_type, status, skb);
spnic_rx_gro(rxq, offload_type, skb); @@ -867,7 +856,7 @@ static inline int recv_supper_cqe(struct spnic_rxq *rxq, struct spnic_rq_cqe *rx #define LRO_PKT_HDR_LEN_IPV4 66 #define LRO_PKT_HDR_LEN_IPV6 86 #define LRO_PKT_HDR_LEN(cqe) \ - (SPNIC_GET_RX_IP_TYPE(sphw_hw_cpu32((cqe)->offload_type)) == \ + (SPNIC_GET_RX_IP_TYPE((cqe)->offload_type) == \ SPNIC_RX_IPV6_PKT ? LRO_PKT_HDR_LEN_IPV6 : LRO_PKT_HDR_LEN_IPV4)
static void stub_rx_recv_jumbo_pkt(struct spnic_rxq *rxq, struct sk_buff *head_skb, @@ -997,7 +986,7 @@ int spnic_rx_poll(struct spnic_rxq *rxq, int budget) while (likely(pkts < budget)) { sw_ci = rxq->cons_idx & rxq->q_mask; rx_cqe = rxq->rx_info[sw_ci].cqe; - status = sphw_hw_cpu32(rx_cqe->status); + status = rx_cqe->status;
if (!SPNIC_GET_RX_DONE(status)) break; @@ -1005,8 +994,8 @@ int spnic_rx_poll(struct spnic_rxq *rxq, int budget) /* make sure we read rx_done before packet length */ rmb();
- vlan_len = sphw_hw_cpu32(rx_cqe->vlan_len); - pkt_info = sphw_hw_cpu32(rx_cqe->pkt_info); + vlan_len = rx_cqe->vlan_len; + pkt_info = rx_cqe->pkt_info; pkt_len = SPNIC_GET_RX_PKT_LEN(vlan_len);
if (unlikely(SPNIC_GET_SUPER_CQE_EN(pkt_info))) { diff --git a/drivers/net/ethernet/ramaxel/spnic/spnic_tx.c b/drivers/net/ethernet/ramaxel/spnic/spnic_tx.c index 57344f89a4dc..7478e76aa729 100644 --- a/drivers/net/ethernet/ramaxel/spnic/spnic_tx.c +++ b/drivers/net/ethernet/ramaxel/spnic/spnic_tx.c @@ -86,9 +86,9 @@ static void txq_stats_init(struct spnic_txq *txq)
static inline void spnic_set_buf_desc(struct spnic_sq_bufdesc *buf_descs, dma_addr_t addr, u32 len) { - buf_descs->hi_addr = sphw_hw_be32(upper_32_bits(addr)); - buf_descs->lo_addr = sphw_hw_be32(lower_32_bits(addr)); - buf_descs->len = sphw_hw_be32(len); + buf_descs->hi_addr = upper_32_bits(addr); + buf_descs->lo_addr = lower_32_bits(addr); + buf_descs->len = len; }
static int tx_map_skb(struct spnic_nic_dev *nic_dev, struct sk_buff *skb, @@ -112,8 +112,8 @@ static int tx_map_skb(struct spnic_nic_dev *nic_dev, struct sk_buff *skb,
dma_info[0].len = skb_headlen(skb);
- wqe_desc->hi_addr = sphw_hw_be32(upper_32_bits(dma_info[0].dma)); - wqe_desc->lo_addr = sphw_hw_be32(lower_32_bits(dma_info[0].dma)); + wqe_desc->hi_addr = upper_32_bits(dma_info[0].dma); + wqe_desc->lo_addr = lower_32_bits(dma_info[0].dma);
wqe_desc->ctrl_len = dma_info[0].len;
@@ -525,12 +525,10 @@ static netdev_tx_t spnic_send_one_skb(struct sk_buff *skb, struct net_device *ne
owner = spnic_set_wqe_combo(txq, &wqe_combo, offload, num_sge, &pi); if (offload) { - /* ip6_frag_id is big endiant, not need to transfer */ - wqe_combo.task->ip_identify = sphw_hw_be32(task.ip_identify); - wqe_combo.task->pkt_info0 = sphw_hw_be32(task.pkt_info0); - wqe_combo.task->pkt_info2 = sphw_hw_be32(task.pkt_info2); - wqe_combo.task->vlan_offload = - sphw_hw_be32(task.vlan_offload); + wqe_combo.task->ip_identify = task.ip_identify; + wqe_combo.task->pkt_info0 = task.pkt_info0; + wqe_combo.task->pkt_info2 = task.pkt_info2; + wqe_combo.task->vlan_offload = task.vlan_offload; }
tx_info = &txq->tx_info[pi];