X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fmlx5%2Fmlx5_txq.c;h=f128c3d1a5b8a65f74cf0adcffcf375e91a8fa18;hb=fe3620aabacd504a2b6c807bd0abe18cc1a2da12;hp=820421f7cd069534f79eea6ba9bfb2796af5d159;hpb=b6e9c33c82582bf88c90220e3a8c1f6a8ace843f;p=dpdk.git diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index 820421f7cd..f128c3d1a5 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -100,34 +100,36 @@ mlx5_get_tx_port_offloads(struct rte_eth_dev *dev) struct mlx5_priv *priv = dev->data->dev_private; uint64_t offloads = (RTE_ETH_TX_OFFLOAD_MULTI_SEGS | RTE_ETH_TX_OFFLOAD_VLAN_INSERT); - struct mlx5_dev_config *config = &priv->config; + struct mlx5_port_config *config = &priv->config; + struct mlx5_dev_cap *dev_cap = &priv->sh->dev_cap; - if (config->hw_csum) + if (dev_cap->hw_csum) offloads |= (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | RTE_ETH_TX_OFFLOAD_UDP_CKSUM | RTE_ETH_TX_OFFLOAD_TCP_CKSUM); - if (config->tso) + if (dev_cap->tso) offloads |= RTE_ETH_TX_OFFLOAD_TCP_TSO; - if (config->tx_pp) + if (priv->sh->config.tx_pp || + priv->sh->cdev->config.hca_attr.wait_on_time) offloads |= RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP; - if (config->swp) { - if (config->swp & MLX5_SW_PARSING_CSUM_CAP) + if (dev_cap->swp) { + if (dev_cap->swp & MLX5_SW_PARSING_CSUM_CAP) offloads |= RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM; - if (config->swp & MLX5_SW_PARSING_TSO_CAP) + if (dev_cap->swp & MLX5_SW_PARSING_TSO_CAP) offloads |= (RTE_ETH_TX_OFFLOAD_IP_TNL_TSO | RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO); } - if (config->tunnel_en) { - if (config->hw_csum) + if (dev_cap->tunnel_en) { + if (dev_cap->hw_csum) offloads |= RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM; - if (config->tso) { - if (config->tunnel_en & + if (dev_cap->tso) { + if (dev_cap->tunnel_en & MLX5_TUNNELED_OFFLOADS_VXLAN_CAP) offloads |= RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO; - if (config->tunnel_en & + if (dev_cap->tunnel_en & MLX5_TUNNELED_OFFLOADS_GRE_CAP) offloads |= RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO; - if (config->tunnel_en & + if (dev_cap->tunnel_en & MLX5_TUNNELED_OFFLOADS_GENEVE_CAP) offloads |= RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO; } @@ -494,66 +496,6 @@ mlx5_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid) mlx5_txq_release(dev, qid); } -/** - * Configure the doorbell register non-cached attribute. - * - * @param txq_ctrl - * Pointer to Tx queue control structure. - * @param page_size - * Systme page size - */ -static void -txq_uar_ncattr_init(struct mlx5_txq_ctrl *txq_ctrl, size_t page_size) -{ - struct mlx5_common_device *cdev = txq_ctrl->priv->sh->cdev; - off_t cmd; - - txq_ctrl->txq.db_heu = cdev->config.dbnc == MLX5_TXDB_HEURISTIC; - txq_ctrl->txq.db_nc = 0; - /* Check the doorbell register mapping type. */ - cmd = txq_ctrl->uar_mmap_offset / page_size; - cmd >>= MLX5_UAR_MMAP_CMD_SHIFT; - cmd &= MLX5_UAR_MMAP_CMD_MASK; - if (cmd == MLX5_MMAP_GET_NC_PAGES_CMD) - txq_ctrl->txq.db_nc = 1; -} - -/** - * Initialize Tx UAR registers for primary process. - * - * @param txq_ctrl - * Pointer to Tx queue control structure. - * @param bf_reg - * BlueFlame register from Verbs UAR. - */ -void -txq_uar_init(struct mlx5_txq_ctrl *txq_ctrl, void *bf_reg) -{ - struct mlx5_priv *priv = txq_ctrl->priv; - struct mlx5_proc_priv *ppriv = MLX5_PROC_PRIV(PORT_ID(priv)); -#ifndef RTE_ARCH_64 - unsigned int lock_idx; -#endif - const size_t page_size = rte_mem_page_size(); - if (page_size == (size_t)-1) { - DRV_LOG(ERR, "Failed to get mem page size"); - rte_errno = ENOMEM; - } - - if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD) - return; - MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY); - MLX5_ASSERT(ppriv); - ppriv->uar_table[txq_ctrl->txq.idx] = bf_reg; - txq_uar_ncattr_init(txq_ctrl, page_size); -#ifndef RTE_ARCH_64 - /* Assign an UAR lock according to UAR page number */ - lock_idx = (txq_ctrl->uar_mmap_offset / page_size) & - MLX5_UAR_PAGE_NUM_MASK; - txq_ctrl->txq.uar_lock = &priv->sh->uar_lock[lock_idx]; -#endif -} - /** * Remap UAR register of a Tx queue for secondary process. * @@ -592,7 +534,7 @@ txq_uar_init_secondary(struct mlx5_txq_ctrl *txq_ctrl, int fd) * As rdma-core, UARs are mapped in size of OS page * size. Ref to libmlx5 function: mlx5_init_context() */ - uar_va = (uintptr_t)primary_ppriv->uar_table[txq->idx]; + uar_va = (uintptr_t)primary_ppriv->uar_table[txq->idx].db; offset = uar_va & (page_size - 1); /* Offset in page. */ addr = rte_mem_map(NULL, page_size, RTE_PROT_WRITE, RTE_MAP_SHARED, fd, txq_ctrl->uar_mmap_offset); @@ -603,7 +545,11 @@ txq_uar_init_secondary(struct mlx5_txq_ctrl *txq_ctrl, int fd) return -rte_errno; } addr = RTE_PTR_ADD(addr, offset); - ppriv->uar_table[txq->idx] = addr; + ppriv->uar_table[txq->idx].db = addr; +#ifndef RTE_ARCH_64 + ppriv->uar_table[txq->idx].sl_p = + primary_ppriv->uar_table[txq->idx].sl_p; +#endif return 0; } @@ -626,7 +572,7 @@ txq_uar_uninit_secondary(struct mlx5_txq_ctrl *txq_ctrl) if (txq_ctrl->type != MLX5_TXQ_TYPE_STANDARD) return; - addr = ppriv->uar_table[txq_ctrl->txq.idx]; + addr = ppriv->uar_table[txq_ctrl->txq.idx].db; rte_mem_unmap(RTE_PTR_ALIGN_FLOOR(addr, page_size), page_size); } @@ -651,9 +597,9 @@ mlx5_tx_uar_uninit_secondary(struct rte_eth_dev *dev) } MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_SECONDARY); for (i = 0; i != ppriv->uar_table_sz; ++i) { - if (!ppriv->uar_table[i]) + if (!ppriv->uar_table[i].db) continue; - addr = ppriv->uar_table[i]; + addr = ppriv->uar_table[i].db; rte_mem_unmap(RTE_PTR_ALIGN_FLOOR(addr, page_size), page_size); } @@ -770,7 +716,7 @@ txq_calc_inline_max(struct mlx5_txq_ctrl *txq_ctrl) struct mlx5_priv *priv = txq_ctrl->priv; unsigned int wqe_size; - wqe_size = priv->sh->device_attr.max_qp_wr / desc; + wqe_size = priv->sh->dev_cap.max_qp_wr / desc; if (!wqe_size) return 0; /* @@ -796,7 +742,8 @@ static void txq_set_params(struct mlx5_txq_ctrl *txq_ctrl) { struct mlx5_priv *priv = txq_ctrl->priv; - struct mlx5_dev_config *config = &priv->config; + struct mlx5_port_config *config = &priv->config; + struct mlx5_dev_cap *dev_cap = &priv->sh->dev_cap; unsigned int inlen_send; /* Inline data for ordinary SEND.*/ unsigned int inlen_empw; /* Inline data for enhanced MPW. */ unsigned int inlen_mode; /* Minimal required Inline data. */ @@ -980,19 +927,19 @@ txq_set_params(struct mlx5_txq_ctrl *txq_ctrl) txq_ctrl->txq.tso_en = 1; } if (((RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO & txq_ctrl->txq.offloads) && - (config->tunnel_en & MLX5_TUNNELED_OFFLOADS_VXLAN_CAP)) | + (dev_cap->tunnel_en & MLX5_TUNNELED_OFFLOADS_VXLAN_CAP)) | ((RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO & txq_ctrl->txq.offloads) && - (config->tunnel_en & MLX5_TUNNELED_OFFLOADS_GRE_CAP)) | + (dev_cap->tunnel_en & MLX5_TUNNELED_OFFLOADS_GRE_CAP)) | ((RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO & txq_ctrl->txq.offloads) && - (config->tunnel_en & MLX5_TUNNELED_OFFLOADS_GENEVE_CAP)) | - (config->swp & MLX5_SW_PARSING_TSO_CAP)) + (dev_cap->tunnel_en & MLX5_TUNNELED_OFFLOADS_GENEVE_CAP)) | + (dev_cap->swp & MLX5_SW_PARSING_TSO_CAP)) txq_ctrl->txq.tunnel_en = 1; txq_ctrl->txq.swp_en = (((RTE_ETH_TX_OFFLOAD_IP_TNL_TSO | RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO) & - txq_ctrl->txq.offloads) && (config->swp & + txq_ctrl->txq.offloads) && (dev_cap->swp & MLX5_SW_PARSING_TSO_CAP)) | ((RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM & - txq_ctrl->txq.offloads) && (config->swp & + txq_ctrl->txq.offloads) && (dev_cap->swp & MLX5_SW_PARSING_CSUM_CAP)); } @@ -1014,7 +961,7 @@ static int txq_adjust_params(struct mlx5_txq_ctrl *txq_ctrl) { struct mlx5_priv *priv = txq_ctrl->priv; - struct mlx5_dev_config *config = &priv->config; + struct mlx5_port_config *config = &priv->config; unsigned int max_inline; max_inline = txq_calc_inline_max(txq_ctrl); @@ -1038,8 +985,7 @@ txq_adjust_params(struct mlx5_txq_ctrl *txq_ctrl) " satisfied (%u) on port %u, try the smaller" " Tx queue size (%d)", txq_ctrl->txq.inlen_mode, max_inline, - priv->dev_data->port_id, - priv->sh->device_attr.max_qp_wr); + priv->dev_data->port_id, priv->sh->dev_cap.max_qp_wr); goto error; } if (txq_ctrl->txq.inlen_send > max_inline && @@ -1050,8 +996,7 @@ txq_adjust_params(struct mlx5_txq_ctrl *txq_ctrl) " satisfied (%u) on port %u, try the smaller" " Tx queue size (%d)", txq_ctrl->txq.inlen_send, max_inline, - priv->dev_data->port_id, - priv->sh->device_attr.max_qp_wr); + priv->dev_data->port_id, priv->sh->dev_cap.max_qp_wr); goto error; } if (txq_ctrl->txq.inlen_empw > max_inline && @@ -1062,8 +1007,7 @@ txq_adjust_params(struct mlx5_txq_ctrl *txq_ctrl) " satisfied (%u) on port %u, try the smaller" " Tx queue size (%d)", txq_ctrl->txq.inlen_empw, max_inline, - priv->dev_data->port_id, - priv->sh->device_attr.max_qp_wr); + priv->dev_data->port_id, priv->sh->dev_cap.max_qp_wr); goto error; } if (txq_ctrl->txq.tso_en && max_inline < MLX5_MAX_TSO_HEADER) { @@ -1072,8 +1016,7 @@ txq_adjust_params(struct mlx5_txq_ctrl *txq_ctrl) " satisfied (%u) on port %u, try the smaller" " Tx queue size (%d)", MLX5_MAX_TSO_HEADER, max_inline, - priv->dev_data->port_id, - priv->sh->device_attr.max_qp_wr); + priv->dev_data->port_id, priv->sh->dev_cap.max_qp_wr); goto error; } if (txq_ctrl->txq.inlen_send > max_inline) { @@ -1135,7 +1078,8 @@ mlx5_txq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, rte_errno = ENOMEM; return NULL; } - if (mlx5_mr_ctrl_init(&tmpl->txq.mr_ctrl, priv->sh->cdev, socket)) { + if (mlx5_mr_ctrl_init(&tmpl->txq.mr_ctrl, + &priv->sh->cdev->mr_scache.dev_gen, socket)) { /* rte_errno is already set. */ goto error; } @@ -1153,12 +1097,12 @@ mlx5_txq_new(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, if (txq_adjust_params(tmpl)) goto error; if (txq_calc_wqebb_cnt(tmpl) > - priv->sh->device_attr.max_qp_wr) { + priv->sh->dev_cap.max_qp_wr) { DRV_LOG(ERR, "port %u Tx WQEBB count (%d) exceeds the limit (%d)," " try smaller queue size", dev->data->port_id, txq_calc_wqebb_cnt(tmpl), - priv->sh->device_attr.max_qp_wr); + priv->sh->dev_cap.max_qp_wr); rte_errno = ENOMEM; goto error; } @@ -1345,12 +1289,21 @@ mlx5_txq_dynf_timestamp_set(struct rte_eth_dev *dev) int off, nbit; unsigned int i; uint64_t mask = 0; + uint64_t ts_mask; + if (sh->dev_cap.rt_timestamp || + !sh->cdev->config.hca_attr.dev_freq_khz) + ts_mask = MLX5_TS_MASK_SECS << 32; + else + ts_mask = rte_align64pow2(MLX5_TS_MASK_SECS * 1000ull * + sh->cdev->config.hca_attr.dev_freq_khz); + ts_mask = rte_cpu_to_be_64(ts_mask - 1ull); nbit = rte_mbuf_dynflag_lookup (RTE_MBUF_DYNFLAG_TX_TIMESTAMP_NAME, NULL); off = rte_mbuf_dynfield_lookup (RTE_MBUF_DYNFIELD_TIMESTAMP_NAME, NULL); - if (nbit >= 0 && off >= 0 && sh->txpp.refcnt) + if (nbit >= 0 && off >= 0 && + (sh->txpp.refcnt || priv->sh->cdev->config.hca_attr.wait_on_time)) mask = 1ULL << nbit; for (i = 0; i != priv->txqs_n; ++i) { data = (*priv->txqs)[i]; @@ -1359,5 +1312,9 @@ mlx5_txq_dynf_timestamp_set(struct rte_eth_dev *dev) data->sh = sh; data->ts_mask = mask; data->ts_offset = off; + data->rt_timestamp = sh->dev_cap.rt_timestamp; + data->rt_timemask = (data->offloads & + RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP) ? + ts_mask : 0; } }