Reviewed-by:Xu Yunxuyun@ramaxel.com
On Fri, 19 Nov 2021 17:46:39 +0800 Yanling Song songyl@ramaxel.com wrote:
Ramaxel inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4J0GH CVE: NA
Support to configure DMA attribute thru firmware
Signed-off-by: Yanling Song songyl@ramaxel.com
.../ramaxel/spnic/hw/sphw_comm_msg_intf.h | 2 +- .../ethernet/ramaxel/spnic/hw/sphw_hw_comm.c | 27 ++++++ .../ethernet/ramaxel/spnic/hw/sphw_hw_comm.h | 3 + .../ethernet/ramaxel/spnic/hw/sphw_hwdev.c | 82 ++++--------------- 4 files changed, 46 insertions(+), 68 deletions(-)
diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_comm_msg_intf.h b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_comm_msg_intf.h index a1abbd054d2a..fd12a47e5bb5 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_comm_msg_intf.h +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_comm_msg_intf.h @@ -135,7 +135,7 @@ struct comm_cmd_msix_config { u8 rsvd2[5]; };
-struct comm_cmd_dma_attr { +struct comm_cmd_dma_attr_config { struct mgmt_msg_head head;
u16 func_id; diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hw_comm.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hw_comm.c index 1629d1e480e2..b868bf8ed1cb 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hw_comm.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hw_comm.c @@ -403,6 +403,33 @@ int sphw_set_ceq_ctrl_reg(struct sphw_hwdev *hwdev, u16 q_id, u32 ctrl0, u32 ctr return 0; }
+int sphw_set_dma_attr_tbl(struct sphw_hwdev *hwdev, u8 entry_idx, u8 st, u8 at, u8 ph,
u8 no_snooping, u8 tph_en)
+{
- struct comm_cmd_dma_attr_config dma_attr;
- u16 out_size = sizeof(dma_attr);
- int err;
- memset(&dma_attr, 0, sizeof(dma_attr));
- dma_attr.func_id = sphw_global_func_id(hwdev);
- dma_attr.entry_idx = entry_idx;
- dma_attr.st = st;
- dma_attr.at = at;
- dma_attr.ph = ph;
- dma_attr.no_snooping = no_snooping;
- dma_attr.tph_en = tph_en;
- err = comm_msg_to_mgmt_sync(hwdev,
COMM_MGMT_CMD_SET_DMA_ATTR, &dma_attr, sizeof(dma_attr),
&dma_attr, &out_size);
- if (err || !out_size || dma_attr.head.status) {
sdk_err(hwdev->dev_hdl, "Failed to set dma_attr,
err: %d, status: 0x%x, out_size: 0x%x\n",
err, dma_attr.head.status, out_size);
return -EIO;
- }
- return 0;
+}
int sphw_set_bdf_ctxt(void *hwdev, u8 bus, u8 device, u8 function) { struct comm_cmd_bdf_info bdf_info; diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hw_comm.h b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hw_comm.h index da37d3ed20ad..4e0cf2dfb21e 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hw_comm.h +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hw_comm.h @@ -34,6 +34,9 @@ int sphw_ppf_ext_db_deinit(void *dev); int sphw_set_ceq_ctrl_reg(struct sphw_hwdev *hwdev, u16 q_id, u32 ctrl0, u32 ctrl1); +int sphw_set_dma_attr_tbl(struct sphw_hwdev *hwdevm, u8 entry_idx, u8 st, u8 at, u8 ph,
u8 no_snooping, u8 tph_en);
int sphw_get_comm_features(void *hwdev, u64 *s_feature, u16 size); int sphw_set_comm_features(void *hwdev, u64 *s_feature, u16 size);
diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c index f58b0325bf04..c88799bcda98 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c @@ -366,89 +366,37 @@ void sphw_detect_hw_present(void *hwdev) }
/**
- set_pf_dma_attr_entry - set the dma attributes for entry
- @hwif: the hardware interface of a pci function device
- @entry_idx: the entry index in the dma table
- @st: PCIE TLP steering tag
- @at: PCIE TLP AT field
- @ph: PCIE TLP Processing Hint field
- @no_snooping: PCIE TLP No snooping
- @tph_en: PCIE TLP Processing Hint Enable
- dma_attr_table_init - initialize the default dma attributes
**/
- @hwdev: the pointer to hw device
-static void set_pf_dma_attr_entry(struct sphw_hwdev *hwdev, u32 entry_idx,
u8 st, u8 at, u8 ph,
enum sphw_pcie_nosnoop no_snooping,
enum sphw_pcie_tph tph_en)
+static int dma_attr_table_init(struct sphw_hwdev *hwdev) {
- u32 addr, val, dma_attr_entry;
u32 addr, val, dst_attr;
/* Use indirect access should set entry_idx first*/ addr = SPHW_CSR_DMA_ATTR_INDIR_IDX_ADDR; val = sphw_hwif_read_reg(hwdev->hwif, addr); val = SPHW_DMA_ATTR_INDIR_IDX_CLEAR(val, IDX);
- entry_idx = SPHW_DMA_ATTR_INDIR_IDX_SET(entry_idx, IDX);
- val |= entry_idx;
- val |= SPHW_DMA_ATTR_INDIR_IDX_SET(PCIE_MSIX_ATTR_ENTRY,
IDX); sphw_hwif_write_reg(hwdev->hwif, addr, val);
wmb(); /* write index before config */
addr = SPHW_CSR_DMA_ATTR_TBL_ADDR;
- val = sphw_hwif_read_reg(hwdev->hwif, addr);
- val = SPHW_DMA_ATTR_ENTRY_CLEAR(val, ST) &
SPHW_DMA_ATTR_ENTRY_CLEAR(val, AT) &
SPHW_DMA_ATTR_ENTRY_CLEAR(val, PH) &
SPHW_DMA_ATTR_ENTRY_CLEAR(val, NO_SNOOPING) &
SPHW_DMA_ATTR_ENTRY_CLEAR(val, TPH_EN);
- dma_attr_entry = SPHW_DMA_ATTR_ENTRY_SET(st, ST) |
SPHW_DMA_ATTR_ENTRY_SET(at, AT) |
SPHW_DMA_ATTR_ENTRY_SET(ph, PH) |
SPHW_DMA_ATTR_ENTRY_SET(no_snooping,
NO_SNOOPING) |
SPHW_DMA_ATTR_ENTRY_SET(tph_en, TPH_EN);
- val |= dma_attr_entry;
- sphw_hwif_write_reg(hwdev->hwif, addr, val);
-}
-static int set_vf_dma_attr_entry(struct sphw_hwdev *hwdev, u8 entry_idx,
u8 st, u8 at, u8 ph,
enum sphw_pcie_nosnoop no_snooping,
enum sphw_pcie_tph tph_en)
-{
- /* SPHW_MGMT_CMD_DMA_ATTR_SET */
- /*to do vf set dma attr by mpu*/
- return 0;
-}
-/**
- dma_attr_table_init - initialize the default dma attributes
- @hwif: the hardware interface of a pci function device
- **/
-static int dma_attr_table_init(struct sphw_hwdev *hwdev) -{
- int err = 0;
- /* TODO: check if set pf dma attr through uP, the same as vf
*/
- if (SPHW_IS_VF(hwdev))
err = set_vf_dma_attr_entry(hwdev,
PCIE_MSIX_ATTR_ENTRY,
SPHW_PCIE_ST_DISABLE,
SPHW_PCIE_AT_DISABLE,
SPHW_PCIE_PH_DISABLE,
SPHW_PCIE_SNOOP,
SPHW_PCIE_TPH_DISABLE);
- else
set_pf_dma_attr_entry(hwdev, PCIE_MSIX_ATTR_ENTRY,
SPHW_PCIE_ST_DISABLE,
SPHW_PCIE_AT_DISABLE,
SPHW_PCIE_PH_DISABLE,
SPHW_PCIE_SNOOP,
SPHW_PCIE_TPH_DISABLE);
- dst_attr = SPHW_DMA_ATTR_ENTRY_SET(SPHW_PCIE_ST_DISABLE,
ST) |
SPHW_DMA_ATTR_ENTRY_SET(SPHW_PCIE_AT_DISABLE,
AT) |
SPHW_DMA_ATTR_ENTRY_SET(SPHW_PCIE_PH_DISABLE,
PH) |
SPHW_DMA_ATTR_ENTRY_SET(SPHW_PCIE_SNOOP,
NO_SNOOPING) |
SPHW_DMA_ATTR_ENTRY_SET(SPHW_PCIE_TPH_DISABLE,
TPH_EN);
- if (dst_attr == val)
return 0;
- return err;
- return sphw_set_dma_attr_tbl(hwdev, PCIE_MSIX_ATTR_ENTRY,
SPHW_PCIE_ST_DISABLE,
SPHW_PCIE_AT_DISABLE,
SPHW_PCIE_PH_DISABLE,
SPHW_PCIE_SNOOP,
SPHW_PCIE_TPH_DISABLE); }
static int init_aeqs_msix_attr(struct sphw_hwdev *hwdev)