diff options
author | 2019-07-04 10:40:06 +0200 | |
---|---|---|
committer | 2019-07-04 10:48:05 +0200 | |
commit | 8d53e9f3c6001dcb2865f6e894da5b54e1418f88 (patch) | |
tree | 63907f21c13636a987d43463c675d0727a04e327 /drivers/net/sfc | |
parent | e2bea7436061ca2e7e14bfcfdc5870f2555c3965 (diff) |
New upstream version 18.11.2upstream-18.11-stable
Change-Id: I23eb4f9179abf1f9c659891f8fddb27ee68ad26b
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Diffstat (limited to 'drivers/net/sfc')
-rw-r--r-- | drivers/net/sfc/sfc.c | 6 | ||||
-rw-r--r-- | drivers/net/sfc/sfc.h | 2 | ||||
-rw-r--r-- | drivers/net/sfc/sfc_debug.h | 3 | ||||
-rw-r--r-- | drivers/net/sfc/sfc_ef10_tx.c | 11 | ||||
-rw-r--r-- | drivers/net/sfc/sfc_ethdev.c | 72 | ||||
-rw-r--r-- | drivers/net/sfc/sfc_mcdi.c | 3 | ||||
-rw-r--r-- | drivers/net/sfc/sfc_rx.c | 22 | ||||
-rw-r--r-- | drivers/net/sfc/sfc_rx.h | 4 | ||||
-rw-r--r-- | drivers/net/sfc/sfc_tso.c | 11 | ||||
-rw-r--r-- | drivers/net/sfc/sfc_tx.c | 3 |
10 files changed, 102 insertions, 35 deletions
diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c index 6690053f..0d7311d6 100644 --- a/drivers/net/sfc/sfc.c +++ b/drivers/net/sfc/sfc.c @@ -1071,8 +1071,8 @@ sfc_unprobe(struct sfc_adapter *sa) } uint32_t -sfc_register_logtype(struct sfc_adapter *sa, const char *lt_prefix_str, - uint32_t ll_default) +sfc_register_logtype(const struct rte_pci_addr *pci_addr, + const char *lt_prefix_str, uint32_t ll_default) { size_t lt_prefix_str_size = strlen(lt_prefix_str); size_t lt_str_size_max; @@ -1092,7 +1092,7 @@ sfc_register_logtype(struct sfc_adapter *sa, const char *lt_prefix_str, strncpy(lt_str, lt_prefix_str, lt_prefix_str_size); lt_str[lt_prefix_str_size - 1] = '.'; - rte_pci_device_name(&sa->pci_addr, lt_str + lt_prefix_str_size, + rte_pci_device_name(pci_addr, lt_str + lt_prefix_str_size, lt_str_size_max - lt_prefix_str_size); lt_str[lt_str_size_max - 1] = '\0'; diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index a94ca8e7..f1cb8300 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -311,7 +311,7 @@ int sfc_dma_alloc(const struct sfc_adapter *sa, const char *name, uint16_t id, size_t len, int socket_id, efsys_mem_t *esmp); void sfc_dma_free(const struct sfc_adapter *sa, efsys_mem_t *esmp); -uint32_t sfc_register_logtype(struct sfc_adapter *sa, +uint32_t sfc_register_logtype(const struct rte_pci_addr *pci_addr, const char *lt_prefix_str, uint32_t ll_default); diff --git a/drivers/net/sfc/sfc_debug.h b/drivers/net/sfc/sfc_debug.h index 6b600ff4..62f3937e 100644 --- a/drivers/net/sfc/sfc_debug.h +++ b/drivers/net/sfc/sfc_debug.h @@ -27,7 +27,8 @@ do { \ const struct sfc_adapter *_sa = (sa); \ \ - rte_panic("sfc " PCI_PRI_FMT " #%" PRIu8 ": " fmt "\n", \ + rte_panic("sfc " PCI_PRI_FMT \ + " #%" PRIu16 ": " fmt "\n", \ _sa->pci_addr.domain, _sa->pci_addr.bus, \ _sa->pci_addr.devid, _sa->pci_addr.function, \ _sa->port_id, ##args); \ diff --git a/drivers/net/sfc/sfc_ef10_tx.c b/drivers/net/sfc/sfc_ef10_tx.c index ff6d5b48..cf229f8b 100644 --- a/drivers/net/sfc/sfc_ef10_tx.c +++ b/drivers/net/sfc/sfc_ef10_tx.c @@ -340,9 +340,7 @@ sfc_ef10_xmit_tso_pkt(struct sfc_ef10_txq * const txq, struct rte_mbuf *m_seg, struct rte_mbuf *m_seg_to_free_up_to = first_m_seg; bool eop; - /* Both checks may be done, so use bit OR to have only one branching */ - if (unlikely((header_len > SFC_TSOH_STD_LEN) | - (tcph_off > txq->tso_tcp_header_offset_limit))) + if (unlikely(tcph_off > txq->tso_tcp_header_offset_limit)) return EMSGSIZE; /* @@ -407,6 +405,13 @@ sfc_ef10_xmit_tso_pkt(struct sfc_ef10_txq * const txq, struct rte_mbuf *m_seg, unsigned int hdr_addr_off = (*added & txq->ptr_mask) * SFC_TSOH_STD_LEN; + /* + * Discard a packet if header linearization is needed but + * the header is too big. + */ + if (unlikely(header_len > SFC_TSOH_STD_LEN)) + return EMSGSIZE; + hdr_addr = txq->tsoh + hdr_addr_off; hdr_iova = txq->tsoh_iova + hdr_addr_off; copied_segs = sfc_tso_prepare_header(hdr_addr, header_len, diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index a7322a1e..052d38cd 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -94,17 +94,17 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) /* Autonegotiation may be disabled */ dev_info->speed_capa = ETH_LINK_SPEED_FIXED; - if (sa->port.phy_adv_cap_mask & EFX_PHY_CAP_1000FDX) + if (sa->port.phy_adv_cap_mask & (1u << EFX_PHY_CAP_1000FDX)) dev_info->speed_capa |= ETH_LINK_SPEED_1G; - if (sa->port.phy_adv_cap_mask & EFX_PHY_CAP_10000FDX) + if (sa->port.phy_adv_cap_mask & (1u << EFX_PHY_CAP_10000FDX)) dev_info->speed_capa |= ETH_LINK_SPEED_10G; - if (sa->port.phy_adv_cap_mask & EFX_PHY_CAP_25000FDX) + if (sa->port.phy_adv_cap_mask & (1u << EFX_PHY_CAP_25000FDX)) dev_info->speed_capa |= ETH_LINK_SPEED_25G; - if (sa->port.phy_adv_cap_mask & EFX_PHY_CAP_40000FDX) + if (sa->port.phy_adv_cap_mask & (1u << EFX_PHY_CAP_40000FDX)) dev_info->speed_capa |= ETH_LINK_SPEED_40G; - if (sa->port.phy_adv_cap_mask & EFX_PHY_CAP_50000FDX) + if (sa->port.phy_adv_cap_mask & (1u << EFX_PHY_CAP_50000FDX)) dev_info->speed_capa |= ETH_LINK_SPEED_50G; - if (sa->port.phy_adv_cap_mask & EFX_PHY_CAP_100000FDX) + if (sa->port.phy_adv_cap_mask & (1u << EFX_PHY_CAP_100000FDX)) dev_info->speed_capa |= ETH_LINK_SPEED_100G; dev_info->max_rx_queues = sa->rxq_max; @@ -860,6 +860,33 @@ fail_inval: } static int +sfc_check_scatter_on_all_rx_queues(struct sfc_adapter *sa, size_t pdu) +{ + const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic); + boolean_t scatter_enabled; + const char *error; + unsigned int i; + + for (i = 0; i < sa->rxq_count; i++) { + if ((sa->rxq_info[i].rxq->state & SFC_RXQ_INITIALIZED) == 0) + continue; + + scatter_enabled = (sa->rxq_info[i].type_flags & + EFX_RXQ_FLAG_SCATTER); + + if (!sfc_rx_check_scatter(pdu, sa->rxq_info[i].rxq->buf_size, + encp->enc_rx_prefix_size, + scatter_enabled, &error)) { + sfc_err(sa, "MTU check for RxQ %u failed: %s", i, + error); + return EINVAL; + } + } + + return 0; +} + +static int sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) { struct sfc_adapter *sa = dev->data->dev_private; @@ -885,6 +912,10 @@ sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) sfc_adapter_lock(sa); + rc = sfc_check_scatter_on_all_rx_queues(sa, pdu); + if (rc != 0) + goto fail_check_scatter; + if (pdu != sa->port.pdu) { if (sa->state == SFC_ADAPTER_STARTED) { sfc_stop(sa); @@ -921,6 +952,8 @@ fail_start: sfc_err(sa, "cannot start with neither new (%u) nor old (%u) " "PDU max size - port is stopped", (unsigned int)pdu, (unsigned int)old_pdu); + +fail_check_scatter: sfc_adapter_unlock(sa); fail_inval: @@ -1124,8 +1157,6 @@ sfc_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) { struct sfc_adapter *sa = dev->data->dev_private; - sfc_log_init(sa, "RxQ=%u", rx_queue_id); - return sfc_rx_qdesc_npending(sa, rx_queue_id); } @@ -1877,7 +1908,7 @@ static const struct eth_dev_ops sfc_eth_dev_secondary_ops = { }; static int -sfc_eth_dev_secondary_set_ops(struct rte_eth_dev *dev) +sfc_eth_dev_secondary_set_ops(struct rte_eth_dev *dev, uint32_t logtype_main) { /* * Device private data has really many process-local pointers. @@ -1891,12 +1922,14 @@ sfc_eth_dev_secondary_set_ops(struct rte_eth_dev *dev) dp_rx = sfc_dp_find_rx_by_name(&sfc_dp_head, sa->dp_rx_name); if (dp_rx == NULL) { - sfc_err(sa, "cannot find %s Rx datapath", sa->dp_rx_name); + SFC_LOG(sa, RTE_LOG_ERR, logtype_main, + "cannot find %s Rx datapath", sa->dp_rx_name); rc = ENOENT; goto fail_dp_rx; } if (~dp_rx->features & SFC_DP_RX_FEAT_MULTI_PROCESS) { - sfc_err(sa, "%s Rx datapath does not support multi-process", + SFC_LOG(sa, RTE_LOG_ERR, logtype_main, + "%s Rx datapath does not support multi-process", sa->dp_rx_name); rc = EINVAL; goto fail_dp_rx_multi_process; @@ -1904,12 +1937,14 @@ sfc_eth_dev_secondary_set_ops(struct rte_eth_dev *dev) dp_tx = sfc_dp_find_tx_by_name(&sfc_dp_head, sa->dp_tx_name); if (dp_tx == NULL) { - sfc_err(sa, "cannot find %s Tx datapath", sa->dp_tx_name); + SFC_LOG(sa, RTE_LOG_ERR, logtype_main, + "cannot find %s Tx datapath", sa->dp_tx_name); rc = ENOENT; goto fail_dp_tx; } if (~dp_tx->features & SFC_DP_TX_FEAT_MULTI_PROCESS) { - sfc_err(sa, "%s Tx datapath does not support multi-process", + SFC_LOG(sa, RTE_LOG_ERR, logtype_main, + "%s Tx datapath does not support multi-process", sa->dp_tx_name); rc = EINVAL; goto fail_dp_tx_multi_process; @@ -1957,27 +1992,30 @@ sfc_eth_dev_init(struct rte_eth_dev *dev) { struct sfc_adapter *sa = dev->data->dev_private; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + uint32_t logtype_main; int rc; const efx_nic_cfg_t *encp; const struct ether_addr *from; sfc_register_dp(); + logtype_main = sfc_register_logtype(&pci_dev->addr, + SFC_LOGTYPE_MAIN_STR, + RTE_LOG_NOTICE); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return -sfc_eth_dev_secondary_set_ops(dev); + return -sfc_eth_dev_secondary_set_ops(dev, logtype_main); /* Required for logging */ sa->pci_addr = pci_dev->addr; sa->port_id = dev->data->port_id; + sa->logtype_main = logtype_main; sa->eth_dev = dev; /* Copy PCI device info to the dev->data */ rte_eth_copy_pci_info(dev, pci_dev); - sa->logtype_main = sfc_register_logtype(sa, SFC_LOGTYPE_MAIN_STR, - RTE_LOG_NOTICE); - rc = sfc_kvargs_parse(sa); if (rc != 0) goto fail_kvargs_parse; diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c index 007506b4..e485e07d 100644 --- a/drivers/net/sfc/sfc_mcdi.c +++ b/drivers/net/sfc/sfc_mcdi.c @@ -256,7 +256,8 @@ sfc_mcdi_init(struct sfc_adapter *sa) if (rc != 0) goto fail_dma_alloc; - mcdi->logtype = sfc_register_logtype(sa, SFC_LOGTYPE_MCDI_STR, + mcdi->logtype = sfc_register_logtype(&sa->pci_addr, + SFC_LOGTYPE_MCDI_STR, RTE_LOG_NOTICE); emtp = &mcdi->transport; diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c index c792e0b2..a78d35a2 100644 --- a/drivers/net/sfc/sfc_rx.c +++ b/drivers/net/sfc/sfc_rx.c @@ -360,6 +360,18 @@ sfc_efx_rx_qdesc_status(struct sfc_dp_rxq *dp_rxq, uint16_t offset) return RTE_ETH_RX_DESC_UNAVAIL; } +boolean_t +sfc_rx_check_scatter(size_t pdu, size_t rx_buf_size, uint32_t rx_prefix_size, + boolean_t rx_scatter_enabled, const char **error) +{ + if ((rx_buf_size < pdu + rx_prefix_size) && !rx_scatter_enabled) { + *error = "Rx scatter is disabled and RxQ mbuf pool object size is too small"; + return B_FALSE; + } + + return B_TRUE; +} + struct sfc_rxq * sfc_rxq_by_dp_rxq(const struct sfc_dp_rxq *dp_rxq) { @@ -964,6 +976,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index, struct sfc_evq *evq; struct sfc_rxq *rxq; struct sfc_dp_rx_qcreate_info info; + const char *error; rc = sa->dp_rx->qsize_up_rings(nb_rx_desc, mb_pool, &rxq_entries, &evq_entries, &rxq_max_fill_level); @@ -987,10 +1000,11 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index, goto fail_bad_conf; } - if ((buf_size < sa->port.pdu + encp->enc_rx_prefix_size) && - (~offloads & DEV_RX_OFFLOAD_SCATTER)) { - sfc_err(sa, "Rx scatter is disabled and RxQ %u mbuf pool " - "object size is too small", sw_index); + if (!sfc_rx_check_scatter(sa->port.pdu, buf_size, + encp->enc_rx_prefix_size, + (offloads & DEV_RX_OFFLOAD_SCATTER), + &error)) { + sfc_err(sa, "RxQ %u MTU check failed: %s", sw_index, error); sfc_err(sa, "RxQ %u calculated Rx buffer size is %u vs " "PDU size %u plus Rx prefix %u bytes", sw_index, buf_size, (unsigned int)sa->port.pdu, diff --git a/drivers/net/sfc/sfc_rx.h b/drivers/net/sfc/sfc_rx.h index 3fba7d8a..65724b03 100644 --- a/drivers/net/sfc/sfc_rx.h +++ b/drivers/net/sfc/sfc_rx.h @@ -159,6 +159,10 @@ int sfc_rx_hf_rte_to_efx(struct sfc_adapter *sa, uint64_t rte, efx_rx_hash_type_t *efx); uint64_t sfc_rx_hf_efx_to_rte(struct sfc_adapter *sa, efx_rx_hash_type_t efx); +boolean_t sfc_rx_check_scatter(size_t pdu, size_t rx_buf_size, + uint32_t rx_prefix_size, + boolean_t rx_scatter_enabled, + const char **error); #ifdef __cplusplus } diff --git a/drivers/net/sfc/sfc_tso.c b/drivers/net/sfc/sfc_tso.c index 076a25d4..a28af0e7 100644 --- a/drivers/net/sfc/sfc_tso.c +++ b/drivers/net/sfc/sfc_tso.c @@ -107,10 +107,6 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, idx += SFC_TSO_OPT_DESCS_NUM; - /* Packets which have too big headers should be discarded */ - if (unlikely(header_len > SFC_TSOH_STD_LEN)) - return EMSGSIZE; - /* * The TCP header must start at most 208 bytes into the frame. * If it starts later than this then the NIC won't realise @@ -129,6 +125,13 @@ sfc_efx_tso_do(struct sfc_efx_txq *txq, unsigned int idx, * limitations on address boundaries crossing by DMA descriptor data. */ if (m->data_len < header_len) { + /* + * Discard a packet if header linearization is needed but + * the header is too big. + */ + if (unlikely(header_len > SFC_TSOH_STD_LEN)) + return EMSGSIZE; + tsoh = txq->sw_ring[idx & txq->ptr_mask].tsoh; sfc_tso_prepare_header(tsoh, header_len, in_seg, in_off); diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c index aa73d264..242137e6 100644 --- a/drivers/net/sfc/sfc_tx.c +++ b/drivers/net/sfc/sfc_tx.c @@ -737,7 +737,8 @@ sfc_efx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) /* We may have reached this place for * one of the following reasons: * - * 1) Packet header length is greater + * 1) Packet header linearization is needed + * and the header length is greater * than SFC_TSOH_STD_LEN * 2) TCP header starts at more then * 208 bytes into the frame |