#define GFP_KERNEL RTE_MEMZONE_IOVA_CONTIG
#define HINIC_PAGE_SHIFT 12
#define HINIC_PAGE_SIZE RTE_PGSIZE_4K
-#define HINIC_MEM_ALLOC_ALIGNE_MIN 8
+#define HINIC_MEM_ALLOC_ALIGN_MIN 8
#define HINIC_PAGE_SIZE_DPDK 6
void *dma_pool_alloc(struct pci_pool *pool, int flags, dma_addr_t *dma_addr);
void dma_pool_free(struct pci_pool *pool, void *vaddr, dma_addr_t dma);
-#define kzalloc(size, flag) rte_zmalloc(NULL, size, HINIC_MEM_ALLOC_ALIGNE_MIN)
+#define kzalloc(size, flag) rte_zmalloc(NULL, size, HINIC_MEM_ALLOC_ALIGN_MIN)
#define kzalloc_aligned(size, flag) rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE)
#define kfree(ptr) rte_free(ptr)
return res;
}
-/**
- * hinic_cpu_to_be32 - convert data to big endian 32 bit format
- * @data: the data to convert
- * @len: length of data to convert, must be Multiple of 4B
- */
-static inline void hinic_cpu_to_be32(void *data, u32 len)
-{
- u32 i;
- u32 *mem = (u32 *)data;
-
- for (i = 0; i < (len >> 2); i++) {
- *mem = cpu_to_be32(*mem);
- mem++;
- }
-}
-
-/**
- * hinic_be32_to_cpu - convert data from big endian 32 bit format
- * @data: the data to convert
- * @len: length of data to convert, must be Multiple of 4B
- */
-static inline void hinic_be32_to_cpu(void *data, u32 len)
-{
- u32 i;
- u32 *mem = (u32 *)data;
-
- for (i = 0; i < (len >> 2); i++) {
- *mem = be32_to_cpu(*mem);
- mem++;
- }
-}
-
static inline int hinic_mutex_init(pthread_mutex_t *pthreadmutex,
const pthread_mutexattr_t *mattr)
{
/**
* chain_busy - check if the chain is still processing last requests
* @chain: chain to check
- **/
+ */
static int chain_busy(struct hinic_api_cmd_chain *chain)
{
switch (chain->chain_type) {
/**
* get_cell_data_size - get the data size of specific cell type
* @type: chain type
- **/
+ */
static u16 get_cell_data_size(enum hinic_api_cmd_chain_type type,
__rte_unused u16 cmd_size)
{
* prepare_cell_ctrl - prepare the ctrl of the cell for the command
* @cell_ctrl: the control of the cell to set the control into it
* @cell_len: the size of the cell
- **/
+ */
static void prepare_cell_ctrl(u64 *cell_ctrl, u16 cell_len)
{
u64 ctrl;
* @dest: destination node on the card that will receive the command
* @cmd: command data
* @cmd_size: the command size
- **/
+ */
static void prepare_api_cmd(struct hinic_api_cmd_chain *chain,
struct hinic_api_cmd_cell *cell,
enum hinic_node_id dest,
* @dest: destination node on the card that will receive the command
* @cmd: command data
* @cmd_size: the command size
- **/
+ */
static void prepare_cell(struct hinic_api_cmd_chain *chain,
enum hinic_node_id dest,
void *cmd, u16 cmd_size)
/**
* api_cmd_status_update - update the status of the chain
* @chain: chain to update
- **/
+ */
static void api_cmd_status_update(struct hinic_api_cmd_chain *chain)
{
struct hinic_api_cmd_status *wb_status;
* wait_for_status_poll - wait for write to mgmt command to complete
* @chain: the chain of the command
* Return: 0 - success, negative - failure
- **/
+ */
static int wait_for_status_poll(struct hinic_api_cmd_chain *chain)
{
unsigned long end;
* wait_for_api_cmd_completion - wait for command to complete
* @chain: chain for the command
* Return: 0 - success, negative - failure
- **/
+ */
static int wait_for_api_cmd_completion(struct hinic_api_cmd_chain *chain,
__rte_unused struct hinic_api_cmd_cell_ctxt *ctxt,
__rte_unused void *ack, __rte_unused u16 ack_size)
* @ack: pointer to messages to response
* @ack_size: the size of ack message
* Return: 0 - success, negative - failure
- **/
+ */
static int api_cmd(struct hinic_api_cmd_chain *chain,
enum hinic_node_id dest,
void *cmd, u16 cmd_size, void *ack, u16 ack_size)
* @cmd: command data
* @size: the command size
* Return: 0 - success, negative - failure
- **/
+ */
int hinic_api_cmd_write(struct hinic_api_cmd_chain *chain,
enum hinic_node_id dest, void *cmd, u16 size)
{
/**
* api_cmd_hw_restart - restart the chain in the HW
* @chain: the API CMD specific chain to restart
- **/
+ */
static int api_cmd_hw_restart(struct hinic_api_cmd_chain *chain)
{
struct hinic_hwif *hwif = chain->hwdev->hwif;
/**
* api_cmd_ctrl_init - set the control register of a chain
* @chain: the API CMD specific chain to set control register for
- **/
+ */
static void api_cmd_ctrl_init(struct hinic_api_cmd_chain *chain)
{
struct hinic_hwif *hwif = chain->hwdev->hwif;
/**
* api_cmd_set_status_addr - set the status address of a chain in the HW
* @chain: the API CMD specific chain to set status address for
- **/
+ */
static void api_cmd_set_status_addr(struct hinic_api_cmd_chain *chain)
{
struct hinic_hwif *hwif = chain->hwdev->hwif;
/**
* api_cmd_set_num_cells - set the number cells of a chain in the HW
* @chain: the API CMD specific chain to set the number of cells for
- **/
+ */
static void api_cmd_set_num_cells(struct hinic_api_cmd_chain *chain)
{
struct hinic_hwif *hwif = chain->hwdev->hwif;
/**
* api_cmd_head_init - set the head cell of a chain in the HW
* @chain: the API CMD specific chain to set the head for
- **/
+ */
static void api_cmd_head_init(struct hinic_api_cmd_chain *chain)
{
struct hinic_hwif *hwif = chain->hwdev->hwif;
* wait_for_ready_chain - wait for the chain to be ready
* @chain: the API CMD specific chain to wait for
* Return: 0 - success, negative - failure
- **/
+ */
static int wait_for_ready_chain(struct hinic_api_cmd_chain *chain)
{
struct hinic_hwif *hwif = chain->hwdev->hwif;
/**
* api_cmd_chain_hw_clean - clean the HW
* @chain: the API CMD specific chain
- **/
+ */
static void api_cmd_chain_hw_clean(struct hinic_api_cmd_chain *chain)
{
struct hinic_hwif *hwif = chain->hwdev->hwif;
*(initialize API command csr)
* @chain: the API CMD specific chain to initialize in HW
* Return: 0 - success, negative - failure
- **/
+ */
static int api_cmd_chain_hw_init(struct hinic_api_cmd_chain *chain)
{
api_cmd_chain_hw_clean(chain);
* free_cmd_buf - free the dma buffer of API CMD command
* @chain: the API CMD specific chain of the cmd
* @cell_idx: the cell index of the cmd
- **/
+ */
static void free_cmd_buf(struct hinic_api_cmd_chain *chain, u32 cell_idx)
{
struct hinic_api_cmd_cell_ctxt *cell_ctxt;
* @cell: the cell in the HW for the cmd
* @cell_idx: the index of the cell
* Return: 0 - success, negative - failure
- **/
+ */
static int alloc_cmd_buf(struct hinic_api_cmd_chain *chain,
struct hinic_api_cmd_cell *cell, u32 cell_idx)
{
* @pre_node: previous cell
* @node_vaddr: the virt addr of the cell
* Return: 0 - success, negative - failure
- **/
+ */
static int api_cmd_create_cell(struct hinic_api_cmd_chain *chain,
u32 cell_idx,
struct hinic_api_cmd_cell *pre_node,
* api_cmd_destroy_cell - destroy API CMD cell of specific chain
* @chain: the API CMD specific chain to destroy its cell
* @cell_idx: the cell to destroy
- **/
+ */
static void api_cmd_destroy_cell(struct hinic_api_cmd_chain *chain,
u32 cell_idx)
{
* api_cmd_destroy_cells - destroy API CMD cells of specific chain
* @chain: the API CMD specific chain to destroy its cells
* @num_cells: number of cells to destroy
- **/
+ */
static void api_cmd_destroy_cells(struct hinic_api_cmd_chain *chain,
u32 num_cells)
{
* api_cmd_create_cells - create API CMD cells for specific chain
* @chain: the API CMD specific chain
* Return: 0 - success, negative - failure
- **/
+ */
static int api_cmd_create_cells(struct hinic_api_cmd_chain *chain)
{
struct hinic_api_cmd_cell *node = NULL, *pre_node = NULL;
* @chain: the API CMD specific chain to initialize
* @attr: attributes to set in the chain
* Return: 0 - success, negative - failure
- **/
+ */
static int api_chain_init(struct hinic_api_cmd_chain *chain,
struct hinic_api_cmd_chain_attr *attr)
{
/**
* api_chain_free - free API CMD specific chain
* @chain: the API CMD specific chain to free
- **/
+ */
static void api_chain_free(struct hinic_api_cmd_chain *chain)
{
void *dev = chain->hwdev;
* @cmd_chain: the API CMD specific chain to create
* @attr: attributes to set in the chain
* Return: 0 - success, negative - failure
- **/
+ */
static int api_cmd_create_chain(struct hinic_api_cmd_chain **cmd_chain,
struct hinic_api_cmd_chain_attr *attr)
{
/**
* api_cmd_destroy_chain - destroy API CMD specific chain
* @chain: the API CMD specific chain to destroy
- **/
+ */
static void api_cmd_destroy_chain(struct hinic_api_cmd_chain *chain)
{
api_cmd_destroy_cells(chain, chain->num_cells);
* @hwdev: the hardware interface of a pci function device
* @chain: the API CMD chains that will be initialized
* Return: 0 - success, negative - failure
- **/
+ */
int hinic_api_cmd_init(struct hinic_hwdev *hwdev,
struct hinic_api_cmd_chain **chain)
{
/**
* hinic_api_cmd_free - free the API CMD chains
* @chain: the API CMD chains that will be freed
- **/
+ */
void hinic_api_cmd_free(struct hinic_api_cmd_chain **chain)
{
enum hinic_api_cmd_chain_type chain_type;
#include "hinic_pmd_mgmt.h"
#include "hinic_pmd_eqs.h"
#include "hinic_pmd_cfg.h"
+#include "hinic_pmd_mbox.h"
bool hinic_support_nic(struct hinic_hwdev *hwdev, struct nic_service_cap *cap)
{
cap->vf_id_start = dev_cap->vf_id_start;
cap->max_sqs = dev_cap->nic_max_sq + 1;
cap->max_rqs = dev_cap->nic_max_rq + 1;
+ } else {
+ cap->max_vf = 0;
+ cap->max_sqs = dev_cap->nic_max_sq;
+ cap->max_rqs = dev_cap->nic_max_rq;
}
cap->chip_svc_type = CFG_SVC_NIC_BIT0;
return 0;
}
+static int get_cap_from_pf(struct hinic_hwdev *dev, enum func_type type)
+{
+ int err;
+ u16 in_len, out_len;
+ struct hinic_dev_cap dev_cap;
+
+ memset(&dev_cap, 0, sizeof(dev_cap));
+ in_len = sizeof(dev_cap);
+ out_len = in_len;
+ err = hinic_mbox_to_pf(dev, HINIC_MOD_CFGM, HINIC_CFG_MBOX_CAP,
+ &dev_cap, in_len, &dev_cap, &out_len,
+ CFG_MAX_CMD_TIMEOUT);
+ if (err || dev_cap.mgmt_msg_head.status || !out_len) {
+ PMD_DRV_LOG(ERR, "Get capability from PF failed, err: %d, status: %d, out_len: %d",
+ err, dev_cap.mgmt_msg_head.status, out_len);
+ return -EFAULT;
+ }
+
+ parse_dev_cap(dev, &dev_cap, type);
+ return 0;
+}
+
static int get_dev_cap(struct hinic_hwdev *dev)
{
int err;
return err;
}
break;
+ case TYPE_VF:
+ err = get_cap_from_pf(dev, type);
+ if (err) {
+ PMD_DRV_LOG(ERR, "Get VF capability failed, err: %d",
+ err);
+ return err;
+ }
+ break;
default:
PMD_DRV_LOG(ERR, "Unsupported PCI function type");
return -EINVAL;
HINIC_MOD_MAX = 15
};
+/* only used by VFD communicating with PFD to register or unregister,
+ * command mode type is HINIC_MOD_L2NIC
+ */
+#define HINIC_PORT_CMD_VF_REGISTER 0x0
+#define HINIC_PORT_CMD_VF_UNREGISTER 0x1
+
/* cmd of mgmt CPU message for NIC module */
enum hinic_port_cmd {
HINIC_PORT_CMD_MGMT_RESET = 0x0,
};
/* total doorbell or direct wqe size is 512kB, db num: 128, dwqe: 128 */
-#define HINIC_DB_DWQE_SIZE 0x00080000
+#define HINIC_DB_DWQE_SIZE 0x00080000
-/* db/dwqe page size: 4K */
-#define HINIC_DB_PAGE_SIZE 0x00001000ULL
+/* db page size: 4K */
+#define HINIC_DB_PAGE_SIZE 0x00001000ULL
-#define HINIC_DB_MAX_AREAS (HINIC_DB_DWQE_SIZE / HINIC_DB_PAGE_SIZE)
+#define HINIC_DB_MAX_AREAS (HINIC_DB_DWQE_SIZE / HINIC_DB_PAGE_SIZE)
#define HINIC_PCI_MSIX_ENTRY_SIZE 16
#define HINIC_PCI_MSIX_ENTRY_VECTOR_CTRL 12
#include "hinic_pmd_cmdq.h"
#include "hinic_pmd_mgmt.h"
#include "hinic_pmd_niccfg.h"
+#include "hinic_pmd_mbox.h"
#define HINIC_DEAULT_EQ_MSIX_PENDING_LIMIT 0
#define HINIC_DEAULT_EQ_MSIX_COALESC_TIMER_CFG 0xFF
"Unrecognized module",
};
+struct hinic_vf_dma_attr_table {
+ struct hinic_mgmt_msg_head mgmt_msg_head;
+
+ u16 func_idx;
+ u8 func_dma_entry_num;
+ u8 entry_idx;
+ u8 st;
+ u8 at;
+ u8 ph;
+ u8 no_snooping;
+ u8 tph_en;
+ u8 resv1[3];
+};
+
+/**
+ * hinic_cpu_to_be32 - convert data to big endian 32 bit format
+ * @data: the data to convert
+ * @len: length of data to convert, must be Multiple of 4B
+ */
+void hinic_cpu_to_be32(void *data, u32 len)
+{
+ u32 i;
+ u32 *mem = (u32 *)data;
+
+ for (i = 0; i < (len >> 2); i++) {
+ *mem = cpu_to_be32(*mem);
+ mem++;
+ }
+}
+
+/**
+ * hinic_be32_to_cpu - convert data from big endian 32 bit format
+ * @data: the data to convert
+ * @len: length of data to convert, must be Multiple of 4B
+ */
+void hinic_be32_to_cpu(void *data, u32 len)
+{
+ u32 i;
+ u32 *mem = (u32 *)data;
+
+ for (i = 0; i < (len >> 2); i++) {
+ *mem = be32_to_cpu(*mem);
+ mem++;
+ }
+}
+
static void *
hinic_dma_mem_zalloc(struct hinic_hwdev *hwdev, size_t size,
dma_addr_t *dma_handle, unsigned int flag, unsigned int align)
{
struct pci_pool *pool;
- pool = rte_zmalloc(NULL, sizeof(*pool), HINIC_MEM_ALLOC_ALIGNE_MIN);
+ pool = rte_zmalloc(NULL, sizeof(*pool), HINIC_MEM_ALLOC_ALIGN_MIN);
if (!pool)
return NULL;
- pool->inuse = 0;
+ rte_atomic32_set(&pool->inuse, 0);
pool->elem_size = size;
pool->align = align;
pool->boundary = boundary;
if (!pool)
return;
- if (pool->inuse != 0) {
- PMD_DRV_LOG(ERR, "Leak memory, dma_pool:%s, inuse_count:%u",
- pool->name, pool->inuse);
+ if (rte_atomic32_read(&pool->inuse) != 0) {
+ PMD_DRV_LOG(ERR, "Leak memory, dma_pool:%s, inuse_count:%d",
+ pool->name, rte_atomic32_read(&pool->inuse));
}
rte_free(pool);
buf = hinic_dma_mem_zalloc(pool->hwdev, pool->elem_size,
dma_addr, flags, (u32)pool->align);
if (buf)
- pool->inuse++;
+ rte_atomic32_inc(&pool->inuse);
return buf;
}
void dma_pool_free(struct pci_pool *pool, void *vaddr, dma_addr_t dma)
{
- pool->inuse--;
+ rte_atomic32_dec(&pool->inuse);
hinic_dma_mem_free(pool->hwdev, pool->elem_size, vaddr, dma);
}
-
-
#define HINIC_MAX_DMA_ENTRIES 8192
int hinic_osdep_init(struct hinic_hwdev *hwdev)
{
}
}
-
-
-
-
-
-
-
-
-
-
-
-
/**
* hinic_set_ci_table - set ci attribute table
* @hwdev: the hardware interface of a nic device
* @return
* 0 on success and ci attribute table is filled,
* negative error value otherwise.
- **/
+ */
int hinic_set_ci_table(void *hwdev, u16 q_id, struct hinic_sq_attr *attr)
{
struct hinic_cons_idx_attr cons_idx_attr;
* @return
* 0 on success,
* negative error value otherwise.
- **/
+ */
int hinic_set_pagesize(void *hwdev, u8 page_size)
{
struct hinic_page_size cmd;
do {
status = hinic_get_pf_status(hwif);
if (status == HINIC_PF_STATUS_FLR_FINISH_FLAG) {
- hinic_set_pf_status(hwif, HINIC_PF_STATUS_ACTIVE_FLAG);
return 0;
}
return err;
}
+static int hinic_vf_rx_tx_flush(struct hinic_hwdev *hwdev)
+{
+ struct hinic_clear_resource clr_res;
+ int err;
+
+ err = wait_cmdq_stop(hwdev);
+ if (err) {
+ PMD_DRV_LOG(WARNING, "Cmdq is still working");
+ return err;
+ }
+
+ memset(&clr_res, 0, sizeof(clr_res));
+ clr_res.func_idx = HINIC_HWIF_GLOBAL_IDX(hwdev->hwif);
+ clr_res.ppf_idx = HINIC_HWIF_PPF_IDX(hwdev->hwif);
+ err = hinic_mbox_to_pf_no_ack(hwdev, HINIC_MOD_COMM,
+ HINIC_MGMT_CMD_START_FLR, &clr_res, sizeof(clr_res));
+ if (err)
+ PMD_DRV_LOG(WARNING, "Notice flush message failed");
+
+ /*
+ * PF firstly set VF doorbell flush csr to be disabled. After PF finish
+ * VF resources flush, PF will set VF doorbell flush csr to be enabled.
+ */
+ err = wait_until_doorbell_flush_states(hwdev->hwif, DISABLE_DOORBELL);
+ if (err)
+ PMD_DRV_LOG(WARNING, "Wait doorbell flush disable timeout");
+
+ err = wait_until_doorbell_flush_states(hwdev->hwif, ENABLE_DOORBELL);
+ if (err)
+ PMD_DRV_LOG(WARNING, "Wait doorbell flush enable timeout");
+
+ err = hinic_reinit_cmdq_ctxts(hwdev);
+ if (err)
+ PMD_DRV_LOG(WARNING, "Reinit cmdq failed");
+
+ return err;
+}
+
/**
* hinic_pf_rx_tx_flush - clean up hardware resource
* @hwdev: the hardware interface of a nic device
* @return
* 0 on success,
* negative error value otherwise.
- **/
+ */
static int hinic_pf_rx_tx_flush(struct hinic_hwdev *hwdev)
{
struct hinic_hwif *hwif = hwdev->hwif;
int hinic_func_rx_tx_flush(struct hinic_hwdev *hwdev)
{
- return hinic_pf_rx_tx_flush(hwdev);
+ if (HINIC_FUNC_TYPE(hwdev) == TYPE_VF)
+ return hinic_vf_rx_tx_flush(hwdev);
+ else
+ return hinic_pf_rx_tx_flush(hwdev);
}
/**
* @hwdev: the hardware interface of a nic device
* @interrupt_info: Information of Interrupt aggregation
* Return: 0 on success, negative error value otherwise.
- **/
+ */
static int hinic_get_interrupt_cfg(struct hinic_hwdev *hwdev,
struct nic_interrupt_info *interrupt_info)
{
* @hwdev: the hardware interface of a nic device
* @interrupt_info: Information of Interrupt aggregation
* Return: 0 on success, negative error value otherwise.
- **/
+ */
int hinic_set_interrupt_cfg(struct hinic_hwdev *hwdev,
struct nic_interrupt_info interrupt_info)
{
* @return
* 0 on success,
* negative error value otherwise.
- **/
+ */
int init_aeqs_msix_attr(void *hwdev)
{
struct hinic_hwdev *nic_hwdev = hwdev;
* @ph: PCIE TLP Processing Hint field
* @no_snooping: PCIE TLP No snooping
* @tph_en: PCIE TLP Processing Hint Enable
- **/
+ */
static void set_pf_dma_attr_entry(struct hinic_hwdev *hwdev, u32 entry_idx,
u8 st, u8 at, u8 ph,
enum hinic_pcie_nosnoop no_snooping,
hinic_hwif_write_reg(hwdev->hwif, addr, val);
}
+static int set_vf_dma_attr_entry(struct hinic_hwdev *hwdev, u8 entry_idx,
+ u8 st, u8 at, u8 ph,
+ enum hinic_pcie_nosnoop no_snooping,
+ enum hinic_pcie_tph tph_en)
+{
+ struct hinic_vf_dma_attr_table attr;
+
+ memset(&attr, 0, sizeof(attr));
+ attr.func_idx = hinic_global_func_id(hwdev);
+ attr.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
+ attr.func_dma_entry_num = hinic_dma_attr_entry_num(hwdev);
+ attr.entry_idx = entry_idx;
+ attr.st = st;
+ attr.at = at;
+ attr.ph = ph;
+ attr.no_snooping = no_snooping;
+ attr.tph_en = tph_en;
+
+ return hinic_msg_to_mgmt_sync(hwdev, HINIC_MOD_COMM,
+ HINIC_MGMT_CMD_DMA_ATTR_SET,
+ &attr, sizeof(attr), NULL, NULL, 0);
+}
+
/**
* dma_attr_table_init - initialize the the default dma attributes
* @hwdev: the pointer to the private hardware device object
- **/
-static void dma_attr_table_init(struct hinic_hwdev *hwdev)
+ */
+static int dma_attr_table_init(struct hinic_hwdev *hwdev)
{
+ int err = 0;
+
if (HINIC_IS_VF(hwdev))
- return;
+ err = set_vf_dma_attr_entry(hwdev, PCIE_MSIX_ATTR_ENTRY,
+ HINIC_PCIE_ST_DISABLE, HINIC_PCIE_AT_DISABLE,
+ HINIC_PCIE_PH_DISABLE, HINIC_PCIE_SNOOP,
+ HINIC_PCIE_TPH_DISABLE);
+ else
+ set_pf_dma_attr_entry(hwdev, PCIE_MSIX_ATTR_ENTRY,
+ HINIC_PCIE_ST_DISABLE, HINIC_PCIE_AT_DISABLE,
+ HINIC_PCIE_PH_DISABLE, HINIC_PCIE_SNOOP,
+ HINIC_PCIE_TPH_DISABLE);
- set_pf_dma_attr_entry(hwdev, PCIE_MSIX_ATTR_ENTRY,
- HINIC_PCIE_ST_DISABLE,
- HINIC_PCIE_AT_DISABLE,
- HINIC_PCIE_PH_DISABLE,
- HINIC_PCIE_SNOOP,
- HINIC_PCIE_TPH_DISABLE);
+ return err;
}
+/**
+ * hinic_init_attr_table - init dma and aeq msix attribute table
+ * @hwdev: the pointer to the private hardware device object
+ */
int hinic_init_attr_table(struct hinic_hwdev *hwdev)
{
- dma_attr_table_init(hwdev);
+ int err;
+
+ err = dma_attr_table_init(hwdev);
+ if (err) {
+ PMD_DRV_LOG(ERR, "Initialize dma attribute table failed, err: %d",
+ err);
+ return err;
+ }
- return init_aeqs_msix_attr(hwdev);
+ err = init_aeqs_msix_attr(hwdev);
+ if (err) {
+ PMD_DRV_LOG(ERR, "Initialize aeqs msix attribute failed, err: %d",
+ err);
+ return err;
+ }
+
+ return 0;
}
#define FAULT_SHOW_STR_LEN 16
* @return
* 0 on success,
* negative error value otherwise.
- **/
+ */
int hinic_activate_hwdev_state(struct hinic_hwdev *hwdev)
{
int rc = HINIC_OK;
if (!hwdev)
return -EINVAL;
- if (!HINIC_IS_VF(hwdev))
- hinic_set_pf_status(hwdev->hwif,
- HINIC_PF_STATUS_ACTIVE_FLAG);
+ hinic_set_pf_status(hwdev->hwif, HINIC_PF_STATUS_ACTIVE_FLAG);
rc = resources_state_set(hwdev, HINIC_RES_ACTIVE);
if (rc) {
* hinic_deactivate_hwdev_state - Deactivate host nic state and notify mgmt
* channel that host nic is not ready.
* @hwdev: the pointer to the private hardware device object
- **/
+ */
void hinic_deactivate_hwdev_state(struct hinic_hwdev *hwdev)
{
int rc = HINIC_OK;
if (rc)
PMD_DRV_LOG(ERR, "Deinit resources state failed");
- if (!HINIC_IS_VF(hwdev))
- hinic_set_pf_status(hwdev->hwif, HINIC_PF_STATUS_INIT);
+ hinic_set_pf_status(hwdev->hwif, HINIC_PF_STATUS_INIT);
}
int hinic_get_board_info(void *hwdev, struct hinic_board_info *info)
* @return
* 0 on success,
* negative error value otherwise.
- **/
+ */
int hinic_l2nic_reset(struct hinic_hwdev *hwdev)
{
struct hinic_hwif *hwif = hwdev->hwif;
/* dma pool */
struct dma_pool {
- u32 inuse;
+ rte_atomic32_t inuse;
size_t elem_size;
size_t align;
size_t boundary;
int hinic_set_pagesize(void *hwdev, u8 page_size);
+void hinic_cpu_to_be32(void *data, u32 len);
+
+void hinic_be32_to_cpu(void *data, u32 len);
+
#endif /* _HINIC_PMD_HWDEV_H_ */
#define HINIC_INTR_MSI_BAR 2
#define HINIC_DB_MEM_BAR 4
+#define PAGE_SIZE_4K 0x1000
+#define PAGE_SIZE_64K 0x10000
+
#define HINIC_MSIX_CNT_RESEND_TIMER_SHIFT 29
#define HINIC_MSIX_CNT_RESEND_TIMER_MASK 0x7U
* hwif_ready - test if the HW initialization passed
* @hwdev: the pointer to the private hardware device object
* Return: 0 - success, negative - failure
- **/
+ */
static int hwif_ready(struct hinic_hwdev *hwdev)
{
- u32 addr, attr1;
+ u32 addr, attr0, attr1;
addr = HINIC_CSR_FUNC_ATTR1_ADDR;
attr1 = hinic_hwif_read_reg(hwdev->hwif, addr);
-
if (!HINIC_AF1_GET(attr1, MGMT_INIT_STATUS))
return -EBUSY;
+ addr = HINIC_CSR_FUNC_ATTR0_ADDR;
+ attr0 = hinic_hwif_read_reg(hwdev->hwif, addr);
+ if ((HINIC_AF0_GET(attr0, FUNC_TYPE) == TYPE_VF) &&
+ !HINIC_AF1_GET(attr1, PF_INIT_STATUS))
+ return -EBUSY;
+
return 0;
}
* @attr0: the first attribute that was read from the hw
* @attr1: the second attribute that was read from the hw
* @attr2: the third attribute that was read from the hw
- **/
+ */
static void set_hwif_attr(struct hinic_hwif *hwif, u32 attr0, u32 attr1,
u32 attr2)
{
/**
* get_hwif_attr - read and set the attributes as members in hwif
* @hwif: the hardware interface of a pci function device
- **/
+ */
static void get_hwif_attr(struct hinic_hwif *hwif)
{
u32 addr, attr0, attr1, attr2;
u32 attr5 = HINIC_AF5_SET(status, PF_STATUS);
u32 addr = HINIC_CSR_FUNC_ATTR5_ADDR;
+ if (hwif->attr.func_type == TYPE_VF) {
+ PMD_DRV_LOG(ERR, "VF doesn't support set attr5");
+ return;
+ }
+
hinic_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
- **/
+ */
static void set_ppf(struct hinic_hwif *hwif)
{
struct hinic_func_attr *attr = &hwif->attr;
hinic_set_msix_state(hwdev, i, HINIC_MSIX_DISABLE);
}
+/**
+ * Wait for up enable or disable doorbell flush finished.
+ * @hwif: the hardware interface of a pci function device.
+ * @states: Disable or Enable.
+ */
+int wait_until_doorbell_flush_states(struct hinic_hwif *hwif,
+ enum hinic_doorbell_ctrl states)
+{
+ unsigned long end;
+ enum hinic_doorbell_ctrl db_ctrl;
+
+ end = jiffies +
+ msecs_to_jiffies(HINIC_WAIT_DOORBELL_AND_OUTBOUND_TIMEOUT);
+ do {
+ db_ctrl = hinic_get_doorbell_ctrl_status(hwif);
+ if (db_ctrl == states)
+ return 0;
+
+ rte_delay_ms(1);
+ } while (time_before(jiffies, end));
+
+ return -EFAULT;
+}
+
static int wait_until_doorbell_and_outbound_enabled(struct hinic_hwif *hwif)
{
unsigned long end;
return hwif->attr.ppf_idx;
}
+/**
+ * hinic_dma_attr_entry_num - get number id of DMA attribute table.
+ * @hwdev: the pointer to the private hardware device object.
+ * Return: The number id of DMA attribute table.
+ */
+u8 hinic_dma_attr_entry_num(void *hwdev)
+{
+ struct hinic_hwif *hwif = ((struct hinic_hwdev *)hwdev)->hwif;
+ return hwif->attr.num_dma_attr;
+}
+
/**
* hinic_init_hwif - initialize the hw interface
* @hwdev: the pointer to the private hardware device object
* @db_base: base virtual address of doorbell registers
* @dwqe_mapping: direct wqe io mapping address
* Return: 0 - success, negative - failure
- **/
+ */
static int hinic_init_hwif(struct hinic_hwdev *hwdev, void *cfg_reg_base,
void *intr_reg_base, u64 db_base_phy,
void *db_base, __rte_unused void *dwqe_mapping)
if (!HINIC_IS_VF(hwdev))
set_ppf(hwif);
+ /* disable mgmt cpu report any event */
+ hinic_set_pf_status(hwdev->hwif, HINIC_PF_STATUS_INIT);
+
return 0;
hwif_ready_err:
void **intr_base, void **db_base)
{
struct rte_pci_device *pci_dev = hwdev->pcidev_hdl;
+ uint64_t bar0_size;
+ uint64_t bar2_size;
+ uint64_t bar0_phy_addr;
+ uint64_t pagesize = sysconf(_SC_PAGESIZE);
*cfg_regs_base = pci_dev->mem_resource[HINIC_CFG_REGS_BAR].addr;
*intr_base = pci_dev->mem_resource[HINIC_INTR_MSI_BAR].addr;
*db_base = pci_dev->mem_resource[HINIC_DB_MEM_BAR].addr;
+
+ bar0_size = pci_dev->mem_resource[HINIC_CFG_REGS_BAR].len;
+ bar2_size = pci_dev->mem_resource[HINIC_INTR_MSI_BAR].len;
+
+ if (pagesize == PAGE_SIZE_64K && (bar0_size % pagesize != 0)) {
+ bar0_phy_addr =
+ pci_dev->mem_resource[HINIC_CFG_REGS_BAR].phys_addr;
+ if (bar0_phy_addr % pagesize != 0 &&
+ (bar0_size + bar2_size <= pagesize) &&
+ bar2_size >= bar0_size) {
+ *cfg_regs_base = (void *)((uint8_t *)(*intr_base)
+ + bar2_size);
+ }
+ }
}
void hinic_hwif_res_free(struct hinic_hwdev *hwdev)
* @hwdev: the hardware interface of a nic device
* @msix_idx: Index of msix interrupt
* @clear_resend_en: enable flag of clear resend configuration
- **/
+ */
void hinic_misx_intr_clear_resend_bit(void *hwdev, u16 msix_idx,
u8 clear_resend_en)
{
HINIC_MSIX_DISABLE,
};
-/* Defines the IRQ information structure*/
+/* Defines the IRQ information structure */
struct irq_info {
u16 msix_entry_idx; /* IRQ corresponding index number */
u32 irq_id; /* the IRQ number from OS */
u8 ppf_idx;
- u16 num_irqs; /* max: 2 ^ 15 */
- u8 num_aeqs; /* max: 2 ^ 3 */
- u8 num_ceqs; /* max: 2 ^ 7 */
+ u16 num_irqs; /* max: 2 ^ 15 */
+ u8 num_aeqs; /* max: 2 ^ 3 */
+ u8 num_ceqs; /* max: 2 ^ 7 */
- u8 num_dma_attr; /* max: 2 ^ 6 */
+ u8 num_dma_attr; /* max: 2 ^ 6 */
u16 global_vf_id_of_pf;
};
void hinic_free_db_addr(void *hwdev, void __iomem *db_base);
+int wait_until_doorbell_flush_states(struct hinic_hwif *hwif,
+ enum hinic_doorbell_ctrl states);
+
void hinic_set_msix_state(void *hwdev, u16 msix_idx,
enum hinic_msix_state flag);
void hinic_hwif_res_free(struct hinic_hwdev *hwdev);
+u8 hinic_dma_attr_entry_num(void *hwdev);
+
#endif /* _HINIC_PMD_HWIF_H_ */
#include "hinic_pmd_hwdev.h"
#include "hinic_pmd_hwif.h"
#include "hinic_pmd_mgmt.h"
+#include "hinic_pmd_mbox.h"
#define BUF_OUT_DEFAULT_SIZE 1
* mgmt_msg_len - calculate the total message length
* @msg_data_len: the length of the message data
* Return: the total message length
- **/
+ */
static u16 mgmt_msg_len(u16 msg_data_len)
{
/* u64 - the size of the header */
* @direction: the direction of the original message
* @cmd: the command to do
* @msg_id: message id
- **/
+ */
static void prepare_header(struct hinic_msg_pf_to_mgmt *pf_to_mgmt,
u64 *header, int msg_len, enum hinic_mod_type mod,
enum hinic_msg_ack_type ack_type,
* @header: pointer of the header to prepare
* @msg: the data of the message
* @msg_len: the length of the message
- **/
+ */
static void prepare_mgmt_cmd(u8 *mgmt_cmd, u64 *header, void *msg,
int msg_len)
{
* alloc_recv_msg - allocate received message memory
* @recv_msg: pointer that will hold the allocated data
* Return: 0 - success, negative - failure
- **/
+ */
static int alloc_recv_msg(struct hinic_recv_msg *recv_msg)
{
int err;
/**
* free_recv_msg - free received message memory
* @recv_msg: pointer that holds the allocated data
- **/
+ */
static void free_recv_msg(struct hinic_recv_msg *recv_msg)
{
kfree(recv_msg->buf_out);
* alloc_msg_buf - allocate all the message buffers of PF to MGMT channel
* @pf_to_mgmt: PF to MGMT channel
* Return: 0 - success, negative - failure
- **/
+ */
static int alloc_msg_buf(struct hinic_msg_pf_to_mgmt *pf_to_mgmt)
{
int err;
* free_msg_buf - free all the message buffers of PF to MGMT channel
* @pf_to_mgmt: PF to MGMT channel
* Return: 0 - success, negative - failure
- **/
+ */
static void free_msg_buf(struct hinic_msg_pf_to_mgmt *pf_to_mgmt)
{
kfree(pf_to_mgmt->sync_msg_buf);
* @direction: the direction of the original message
* @resp_msg_id: message id of response
* Return: 0 - success, negative - failure
- **/
+ */
static int send_msg_to_mgmt_async(struct hinic_msg_pf_to_mgmt *pf_to_mgmt,
enum hinic_mod_type mod, u8 cmd,
void *msg, u16 msg_len,
* @direction: the direction of the original message
* @resp_msg_id: msg id to response for
* Return: 0 - success, negative - failure
- **/
+ */
static int send_msg_to_mgmt_sync(struct hinic_msg_pf_to_mgmt *pf_to_mgmt,
enum hinic_mod_type mod, u8 cmd,
void *msg, u16 msg_len,
* hinic_pf_to_mgmt_init - initialize PF to MGMT channel
* @hwdev: the pointer to the private hardware device object
* Return: 0 - success, negative - failure
- **/
+ */
static int hinic_pf_to_mgmt_init(struct hinic_hwdev *hwdev)
{
struct hinic_msg_pf_to_mgmt *pf_to_mgmt;
hwdev->pf_to_mgmt = pf_to_mgmt;
pf_to_mgmt->hwdev = hwdev;
- err = hinic_mutex_init(&pf_to_mgmt->sync_msg_lock, NULL);
+ err = hinic_mutex_init(&pf_to_mgmt->sync_msg_mutex, NULL);
if (err)
goto mutex_init_err;
free_msg_buf(pf_to_mgmt);
alloc_msg_buf_err:
- hinic_mutex_destroy(&pf_to_mgmt->sync_msg_lock);
+ hinic_mutex_destroy(&pf_to_mgmt->sync_msg_mutex);
mutex_init_err:
kfree(pf_to_mgmt);
/**
* hinic_pf_to_mgmt_free - free PF to MGMT channel
* @hwdev: the pointer to the private hardware device object
- **/
+ */
static void hinic_pf_to_mgmt_free(struct hinic_hwdev *hwdev)
{
struct hinic_msg_pf_to_mgmt *pf_to_mgmt = hwdev->pf_to_mgmt;
hinic_api_cmd_free(pf_to_mgmt->cmd_chain);
free_msg_buf(pf_to_mgmt);
- hinic_mutex_destroy(&pf_to_mgmt->sync_msg_lock);
+ hinic_mutex_destroy(&pf_to_mgmt->sync_msg_mutex);
kfree(pf_to_mgmt);
}
u32 timeo;
int err, i;
- pthread_mutex_lock(&pf_to_mgmt->sync_msg_lock);
+ err = hinic_mutex_lock(&pf_to_mgmt->sync_msg_mutex);
+ if (err)
+ return err;
SYNC_MSG_ID_INC(pf_to_mgmt);
recv_msg = &pf_to_mgmt->recv_resp_msg_from_mgmt;
unlock_sync_msg:
if (err && out_size)
*out_size = 0;
- pthread_mutex_unlock(&pf_to_mgmt->sync_msg_lock);
+ (void)hinic_mutex_unlock(&pf_to_mgmt->sync_msg_mutex);
return err;
}
struct hinic_hwif *hwif = ((struct hinic_hwdev *)hwdev)->hwif;
u32 val;
+ if (hinic_func_type((struct hinic_hwdev *)hwdev) == TYPE_VF)
+ return false;
+
val = hinic_hwif_read_reg(hwif, HINIC_ICPL_RESERVD_ADDR);
return HINIC_GET_MGMT_CHANNEL_STATUS(val, MGMT_CHANNEL_STATUS);
if (hinic_get_mgmt_channel_status(hwdev))
return -EPERM;
- rc = hinic_pf_to_mgmt_sync(hwdev, mod, cmd, buf_in,
- in_size, buf_out, out_size,
- timeout);
+ if (hinic_func_type(hwdev) == TYPE_VF) {
+ rc = hinic_mbox_to_pf(hwdev, mod, cmd, buf_in, in_size,
+ buf_out, out_size, timeout);
+ } else {
+ rc = hinic_pf_to_mgmt_sync(hwdev, mod, cmd, buf_in, in_size,
+ buf_out, out_size, timeout);
+ }
return rc;
}
return err;
}
- pthread_mutex_lock(&pf_to_mgmt->sync_msg_lock);
+ err = hinic_mutex_lock(&pf_to_mgmt->sync_msg_mutex);
+ if (err)
+ return err;
err = send_msg_to_mgmt_sync(pf_to_mgmt, mod, cmd, buf_in, in_size,
HINIC_MSG_NO_ACK, HINIC_MSG_DIRECT_SEND,
MSG_NO_RESP);
- pthread_mutex_unlock(&pf_to_mgmt->sync_msg_lock);
+ (void)hinic_mutex_unlock(&pf_to_mgmt->sync_msg_mutex);
return err;
}
* @pf_to_mgmt: PF to MGMT channel
* @recv_msg: received message details
* @param: customized parameter
- **/
+ */
static void hinic_mgmt_recv_msg_handler(struct hinic_msg_pf_to_mgmt *pf_to_mgmt,
struct hinic_recv_msg *recv_msg,
void *param)
* @param: customized parameter
* Return: 0 when aeq is response message, -1 default result,
* and when wrong message or not last message
- **/
+ */
static int recv_mgmt_msg_handler(struct hinic_msg_pf_to_mgmt *pf_to_mgmt,
u8 *header, struct hinic_recv_msg *recv_msg,
void *param)
"func id: 0x%x, front id: 0x%x, current id: 0x%x, seg len: 0x%x",
hinic_global_func_id(pf_to_mgmt->hwdev),
recv_msg->sed_id, seq_id, seq_len);
- return HINIC_RECV_NEXT_AEQE;
+ return HINIC_ERROR;
}
dest_msg = (u8 *)recv_msg->msg + seq_id * HINIC_MSG_SEG_LEN;
memcpy(dest_msg, msg_body, seq_len);
if (!HINIC_MSG_HEADER_GET(msg_header, LAST))
- return HINIC_RECV_NEXT_AEQE;
+ return HINIC_ERROR;
recv_msg->cmd = HINIC_MSG_HEADER_GET(msg_header, CMD);
recv_msg->mod = HINIC_MSG_HEADER_GET(msg_header, MODULE);
recv_msg->msg_id = HINIC_MSG_HEADER_GET(msg_header, MSG_ID);
if (HINIC_MSG_HEADER_GET(msg_header, DIRECTION) == HINIC_MSG_RESPONSE)
- return HINIC_RECV_DONE;
+ return HINIC_OK;
hinic_mgmt_recv_msg_handler(pf_to_mgmt, recv_msg, param);
- return HINIC_RECV_NEXT_AEQE;
+ return HINIC_ERROR;
}
/**
* @param: customized parameter
* Return: 0 when aeq is response message,
* -1 default result, and when wrong message or not last message
- **/
+ */
static int hinic_mgmt_msg_aeqe_handler(void *hwdev, u8 *header,
__rte_unused u8 size, void *param)
{
case HINIC_MSG_FROM_MGMT_CPU:
rc = hinic_mgmt_msg_aeqe_handler(handle, data, size, param);
break;
+ case HINIC_MBX_FROM_FUNC:
+ rc = hinic_mbox_func_aeqe_handler(handle, data, size, param);
+ break;
default:
PMD_DRV_LOG(ERR, "Unknown event type: 0x%x, size: %d",
event, size);
- rc = HINIC_RECV_NEXT_AEQE;
+ rc = HINIC_ERROR;
break;
}
* used in polling mode.
* @param: customized parameter
* Return: 0 - Success, EIO - poll timeout, ENODEV - swe not support
- **/
+ */
int hinic_aeq_poll_msg(struct hinic_eq *eq, u32 timeout, void *param)
{
struct hinic_aeq_elem *aeqe_pos;
{
int rc;
+ /* VF do not support send msg to mgmt directly */
+ if (hinic_func_type(hwdev) == TYPE_VF)
+ return 0;
+
rc = hinic_pf_to_mgmt_init(hwdev);
if (rc)
return rc;
void hinic_comm_pf_to_mgmt_free(struct hinic_hwdev *hwdev)
{
+ /* VF do not support send msg to mgmt directly */
+ if (hinic_func_type(hwdev) == TYPE_VF)
+ return;
+
hinic_pf_to_mgmt_free(hwdev);
}
struct hinic_hwdev *hwdev;
/* mutex for sync message */
- pthread_mutex_t sync_msg_lock;
+ pthread_mutex_t sync_msg_mutex;
void *async_msg_buf;
void *sync_msg_buf;
#include "hinic_pmd_mgmt.h"
#include "hinic_pmd_cmdq.h"
#include "hinic_pmd_niccfg.h"
+#include "hinic_pmd_mbox.h"
#define l2nic_msg_to_mgmt_sync(hwdev, cmd, buf_in, \
in_size, buf_out, out_size) \
buf_in, in_size, \
buf_out, out_size, 0)
+/**
+ * hinic_init_function_table - Initialize function table.
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ * @param rx_buf_sz
+ * Receive buffer size.
+ *
+ * @return
+ * 0 on success.
+ * negative error value otherwise.
+ */
int hinic_init_function_table(void *hwdev, u16 rx_buf_sz)
{
struct hinic_function_table function_table;
&function_table, &out_size, 0);
if (err || function_table.mgmt_msg_head.status || !out_size) {
PMD_DRV_LOG(ERR,
- "Failed to init func table, ret = %d",
- function_table.mgmt_msg_head.status);
+ "Failed to init func table, err: %d, status: 0x%x, out size: 0x%x",
+ err, function_table.mgmt_msg_head.status, out_size);
return -EFAULT;
}
}
/**
- * hinic_get_base_qpn - get global number of queue
- * @hwdev: the hardware interface of a nic device
- * @global_qpn: vat page size
+ * hinic_get_base_qpn - Get global queue number.
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ * @param global_qpn
+ * Global queue number.
+ *
* @return
- * 0 on success,
+ * 0 on success.
* negative error value otherwise.
- **/
+ */
int hinic_get_base_qpn(void *hwdev, u16 *global_qpn)
{
struct hinic_cmd_qpn cmd_qpn;
&out_size, 0);
if (err || !out_size || cmd_qpn.mgmt_msg_head.status) {
PMD_DRV_LOG(ERR,
- "Failed to get base qpn, status(%d)",
- cmd_qpn.mgmt_msg_head.status);
+ "Failed to get base qpn, err: %d, status: 0x%x, out size: 0x%x",
+ err, cmd_qpn.mgmt_msg_head.status, out_size);
return -EINVAL;
}
/**
* hinic_set_mac - Init mac_vlan table in NIC.
- * @hwdev: the hardware interface of a nic device
- * @mac_addr: mac address
- * @vlan_id: set 0 for mac_vlan table initialization
- * @func_id: global function id of NIC
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ * @param mac_addr
+ * MAC address.
+ * @param vlan_id
+ * Set 0 for mac_vlan table initialization.
+ * @param func_id
+ * Global function id of NIC.
+ *
* @return
- * 0 on success and stats is filled,
+ * 0 on success.
* negative error value otherwise.
*/
int hinic_set_mac(void *hwdev, u8 *mac_addr, u16 vlan_id, u16 func_id)
err, mac_info.mgmt_msg_head.status, out_size);
return -EINVAL;
}
+
if (mac_info.mgmt_msg_head.status == HINIC_PF_SET_VF_ALREADY) {
PMD_DRV_LOG(WARNING, "PF has already set vf mac, Ignore set operation.");
return HINIC_PF_SET_VF_ALREADY;
/**
* hinic_del_mac - Uninit mac_vlan table in NIC.
- * @hwdev: the hardware interface of a nic device
- * @mac_addr: mac address
- * @vlan_id: set 0 for mac_vlan table initialization
- * @func_id: global function id of NIC
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ * @param mac_addr
+ * MAC address.
+ * @param vlan_id
+ * Set 0 for mac_vlan table initialization.
+ * @param func_id
+ * Global function id of NIC.
+ *
* @return
- * 0 on success and stats is filled,
+ * 0 on success.
* negative error value otherwise.
*/
-int hinic_del_mac(void *hwdev, u8 *mac_addr, u16 vlan_id,
- u16 func_id)
+int hinic_del_mac(void *hwdev, u8 *mac_addr, u16 vlan_id, u16 func_id)
{
struct hinic_port_mac_set mac_info;
u16 out_size = sizeof(mac_info);
return 0;
}
+/**
+ * hinic_get_default_mac - Get default mac address from hardware.
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ * @param mac_addr
+ * MAC address.
+ *
+ * @return
+ * 0 on success.
+ * negative error value otherwise.
+ */
int hinic_get_default_mac(void *hwdev, u8 *mac_addr)
{
struct hinic_port_mac_set mac_info;
return 0;
}
+/**
+ * hinic_set_port_mtu - Set MTU to port.
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ * @param new_mtu
+ * MTU size.
+ *
+ * @return
+ * 0 on success.
+ * negative error value otherwise.
+ */
int hinic_set_port_mtu(void *hwdev, u32 new_mtu)
{
struct hinic_mtu mtu_info;
return 0;
}
+/**
+ * hinic_get_link_status - Get link status from hardware.
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ * @param link_state
+ * Link status.
+ *
+ * @return
+ * 0 on success.
+ * negative error value otherwise.
+ */
int hinic_get_link_status(void *hwdev, u8 *link_state)
{
struct hinic_get_link get_link;
/**
* hinic_set_vport_enable - Notify firmware that driver is ready or not.
- * @hwdev: the hardware interface of a nic device
- * @enable: 1: driver is ready; 0: driver is not ok.
- * Return: 0 on success and state is filled, negative error value otherwise.
- **/
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ * @param enable
+ * 1: driver is ready; 0: driver is not ok.
+ *
+ * @return
+ * 0 on success.
+ * negative error value otherwise.
+ */
int hinic_set_vport_enable(void *hwdev, bool enable)
{
struct hinic_vport_state en_state;
}
/**
- * hinic_set_port_enable - open MAG to receive packets.
- * @hwdev: the hardware interface of a nic device
- * @enable: 1: open MAG; 0: close MAG.
+ * hinic_set_port_enable - Open MAG to receive packets.
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ * @param enable
+ * 1: open MAG; 0: close MAG.
+ *
* @return
- * 0 on success and stats is filled,
+ * 0 on success.
* negative error value otherwise.
*/
int hinic_set_port_enable(void *hwdev, bool enable)
return -EINVAL;
}
+ if (HINIC_IS_VF((struct hinic_hwdev *)hwdev))
+ return 0;
+
memset(&en_state, 0, sizeof(en_state));
en_state.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
en_state.state = (enable ? HINIC_PORT_ENABLE : HINIC_PORT_DISABLE);
memset(&ets, 0, sizeof(ets));
ets.mgmt_msg_head.resp_aeq_num = HINIC_AEQ1;
- ets.port_id = 0; /* reserved */
+ ets.port_id = 0; /* reserved */
memcpy(ets.up_tc, up_tc, HINIC_DCB_TC_MAX);
memcpy(ets.pg_bw, pg_bw, HINIC_DCB_UP_MAX);
memcpy(ets.pgid, pgid, HINIC_DCB_UP_MAX);
}
/**
- * hinic_rss_set_hash_engine - Init rss hash function .
- * @hwdev: the hardware interface of a nic device
- * @tmpl_idx: index of rss template from NIC.
- * @type: hash function, such as Toeplitz or XOR.
+ * hinic_rss_set_hash_engine - Init rss hash function.
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ * @param tmpl_idx
+ * Index of rss template from NIC.
+ * @param type
+ * Hash function, such as Toeplitz or XOR.
+ *
* @return
- * 0 on success and stats is filled,
+ * 0 on success.
* negative error value otherwise.
*/
int hinic_rss_set_hash_engine(void *hwdev, u8 tmpl_idx, u8 type)
}
/**
- * hinic_rss_template_alloc - get rss template id from the chip,
- * all functions share 96 templates.
- * @hwdev: the pointer to the private hardware device object
- * @tmpl_idx: index of rss template from chip.
- * Return: 0 on success and stats is filled, negative error value otherwise.
- **/
+ * hinic_rss_template_alloc - Get rss template id from the chip,
+ * all functions share 96 templates.
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ * @param tmpl_idx
+ * Index of rss template from chip.
+ *
+ * @return
+ * 0 on success.
+ * negative error value otherwise.
+ */
int hinic_rss_template_alloc(void *hwdev, u8 *tmpl_idx)
{
struct hinic_rss_template_mgmt template_mgmt;
}
/**
- * hinic_rss_template_alloc - free rss template id to the chip
- * @hwdev: the hardware interface of a nic device
- * @tmpl_idx: index of rss template from NIC.
- * Return: 0 on success and stats is filled, negative error value otherwise.
- **/
+ * hinic_rss_template_free - Free rss template id to the chip.
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ * @param tmpl_idx
+ * Index of rss template from chip.
+ *
+ * @return
+ * 0 on success.
+ * negative error value otherwise.
+ */
int hinic_rss_template_free(void *hwdev, u8 tmpl_idx)
{
struct hinic_rss_template_mgmt template_mgmt;
}
/**
- * hinic_set_rx_vhd_mode - change rx buffer size after initialization,
- * @hwdev: the hardware interface of a nic device
- * @mode: not needed.
- * @rx_buf_sz: receive buffer size.
+ * hinic_set_rx_vhd_mode - Change rx buffer size after initialization.
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ * @param vhd_mode
+ * Not needed.
+ * @param rx_buf_sz
+ * receive buffer size.
+ *
* @return
- * 0 on success and stats is filled,
+ * 0 on success.
* negative error value otherwise.
*/
int hinic_set_rx_vhd_mode(void *hwdev, u16 vhd_mode, u16 rx_buf_sz)
return 0;
}
+/**
+ * hinic_vf_func_init - Register VF to PF.
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ *
+ * @return
+ * 0 on success.
+ * negative error value otherwise.
+ */
+int hinic_vf_func_init(struct hinic_hwdev *hwdev)
+{
+ int err, state = 0;
+
+ if (!HINIC_IS_VF(hwdev))
+ return 0;
+
+ err = hinic_mbox_to_pf(hwdev, HINIC_MOD_L2NIC,
+ HINIC_PORT_CMD_VF_REGISTER, &state, sizeof(state),
+ NULL, NULL, 0);
+ if (err) {
+ PMD_DRV_LOG(ERR, "Fail to register vf");
+ return err;
+ }
+
+ return 0;
+}
+
+/**
+ * hinic_vf_func_free - Unregister VF from PF.
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ */
+void hinic_vf_func_free(struct hinic_hwdev *hwdev)
+{
+ int err;
+
+ if (hinic_func_type(hwdev) != TYPE_VF)
+ return;
+
+ err = hinic_mbox_to_pf(hwdev, HINIC_MOD_L2NIC,
+ HINIC_PORT_CMD_VF_UNREGISTER, &err, sizeof(err),
+ NULL, NULL, 0);
+ if (err)
+ PMD_DRV_LOG(ERR, "Fail to unregister VF, err: %d", err);
+}
+
int hinic_set_fast_recycle_mode(void *hwdev, u8 mode)
{
struct hinic_fast_recycled_mode fast_recycled_mode;
if (!hwdev)
return -EINVAL;
+ if (HINIC_IS_VF((struct hinic_hwdev *)hwdev))
+ return 0;
+
if (status >= HINIC_LINK_FOLLOW_STATUS_MAX) {
PMD_DRV_LOG(ERR,
"Invalid link follow status: %d", status);
}
/**
- * hinic_flush_qp_res - Flush tx && rx chip resources in case of set vport fake
- * failed when device start.
- * @hwdev: the hardware interface of a nic device
- * Return: 0 on success, negative error value otherwise.
- **/
+ * hinic_flush_qp_res - Flush tx && rx chip resources in case of set vport
+ * fake failed when device start.
+ *
+ * @param hwdev
+ * The hardware interface of a nic device.
+ *
+ * @return
+ * 0 on success.
+ * negative error value otherwise.
+ */
int hinic_flush_qp_res(void *hwdev)
{
struct hinic_clear_qp_resource qp_res;
int hinic_clear_phy_port_stats(struct hinic_hwdev *hwdev);
+int hinic_vf_func_init(struct hinic_hwdev *hwdev);
+
+void hinic_vf_func_free(struct hinic_hwdev *hwdev);
+
#endif /* _HINIC_PMD_NICCFG_H_ */
* @rx_buf_sz: receive buffer size
* @return
* hw rx buffer size
- **/
+ */
static u16 get_hw_rx_buf_size(u32 rx_buf_sz)
{
u16 num_hw_types = sizeof(hinic_hw_rx_buf_size)
* @sq_depth: the depth of transmit queue
* @rx_buf_sz: receive buffer size from app
* Return: 0 on success, negative error value otherwise.
- **/
+ */
static int
hinic_set_root_ctxt(void *hwdev, u16 rq_depth, u16 sq_depth, int rx_buf_sz)
{
* @return
* 0 on success,
* negative error value otherwise.
- **/
+ */
static int hinic_clean_root_ctxt(void *hwdev)
{
struct hinic_root_ctxt root_ctxt;
goto err_init_nic_hwdev;
}
+ err = hinic_vf_func_init(hwdev);
+ if (err) {
+ PMD_DRV_LOG(ERR, "Failed to init nic mbox");
+ goto err_init_nic_hwdev;
+ }
+
err = hinic_set_fast_recycle_mode(hwdev, RECYCLE_MODE_DPDK);
if (err) {
PMD_DRV_LOG(ERR, "Failed to set fast recycle mode");
static void hinic_free_nic_hwdev(struct hinic_hwdev *hwdev)
{
+ hinic_vf_func_free(hwdev);
hwdev->nic_io = NULL;
}
* @return
* 0 on success,
* negative error value otherwise.
- **/
+ */
int hinic_convert_rx_buf_size(u32 rx_buf_sz, u32 *match_sz)
{
u32 i, num_hw_types, best_match_sz;
u16 vhd_mode;
struct hinic_qp *qps;
- /* sq ci mem base addr of the function*/
+ /* sq ci mem base addr of the function */
void *ci_vaddr_base;
dma_addr_t ci_dma_base;
u32 db_info;
};
-
int hinic_init_qp_ctxts(struct hinic_hwdev *hwdev);
void hinic_free_qp_ctxts(struct hinic_hwdev *hwdev);