History

net: hns3: default enable tx bounce buffer when smmu enabled

The SMMU engine on HIP09 chip has a hardware issue. SMMU pagetable prefetch features may prefetch and use a invalid PTE even the PTE is valid at that time. This will cause the device trigger fake pagefaults. The solution is to avoid prefetching by adding a SYNC command when smmu mapping a iova. But the performance of nic has a sharp drop. Then we do this workaround, always enable tx bounce buffer, avoid mapping/unmapping on TX path. This issue only affects HNS3, so we always enable tx bounce buffer when smmu enabled to improve performance.

Jijie Shao committed 1 year ago

Commit 49ade861 parent b3e75c02 files · +33 −0Browse files

Unified · Split

2 files
  1. drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +31 −0
  2. drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +2 −0
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c+31−0
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 #include <linux/irq.h>
1212 #include <linux/ip.h>
1313 #include <linux/ipv6.h>
14+#include <linux/iommu.h>
1415 #include <linux/module.h>
1516 #include <linux/pci.h>
1617 #include <linux/skbuff.h>
@@ -1039,6 +1040,8 @@ static bool hns3_can_use_tx_sgl(struct hns3_enet_ring *ring, · 1022 unmodified lines
10391040 static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring)
10401041 {
10411042 u32 alloc_size = ring->tqp->handle->kinfo.tx_spare_buf_size;
1043+ struct net_device *netdev = ring_to_netdev(ring);
1044+ struct hns3_nic_priv *priv = netdev_priv(netdev);
10421045 struct hns3_tx_spare *tx_spare;
10431046 struct page *page;
10441047 dma_addr_t dma;
@@ -1080,6 +1083,7 @@ static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring) · 35 unmodified lines
10801083 tx_spare->buf = page_address(page);
10811084 tx_spare->len = PAGE_SIZE << order;
10821085 ring->tx_spare = tx_spare;
1086+ ring->tx_copybreak = priv->tx_copybreak;
10831087 return;
10841088
10851089 dma_mapping_error:
@@ -4874,6 +4878,30 @@ static void hns3_nic_dealloc_vector_data(struct hns3_nic_priv *priv) · 3788 unmodified lines
48744878 devm_kfree(&pdev->dev, priv->tqp_vector);
48754879 }
48764880
4881+static void hns3_update_tx_spare_buf_config(struct hns3_nic_priv *priv)
4882+{
4883+#define HNS3_MIN_SPARE_BUF_SIZE (2 * 1024 * 1024)
4884+#define HNS3_MAX_PACKET_SIZE (64 * 1024)
4885+
4886+ struct iommu_domain *domain = iommu_get_domain_for_dev(priv->dev);
4887+ struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(priv->ae_handle);
4888+ struct hnae3_handle *handle = priv->ae_handle;
4889+
4890+ if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V3)
4891+ return;
4892+
4893+ if (!(domain && iommu_is_dma_domain(domain)))
4894+ return;
4895+
4896+ priv->min_tx_copybreak = HNS3_MAX_PACKET_SIZE;
4897+ priv->min_tx_spare_buf_size = HNS3_MIN_SPARE_BUF_SIZE;
4898+
4899+ if (priv->tx_copybreak < priv->min_tx_copybreak)
4900+ priv->tx_copybreak = priv->min_tx_copybreak;
4901+ if (handle->kinfo.tx_spare_buf_size < priv->min_tx_spare_buf_size)
4902+ handle->kinfo.tx_spare_buf_size = priv->min_tx_spare_buf_size;
4903+}
4904+
48774905 static void hns3_ring_get_cfg(struct hnae3_queue *q, struct hns3_nic_priv *priv,
48784906 unsigned int ring_type)
48794907 {
@@ -5107,6 +5135,7 @@ int hns3_init_all_ring(struct hns3_nic_priv *priv) · 227 unmodified lines
51075135 int i, j;
51085136 int ret;
51095137
5138+ hns3_update_tx_spare_buf_config(priv);
51105139 for (i = 0; i < ring_num; i++) {
51115140 ret = hns3_alloc_ring_memory(&priv->ring[i]);
51125141 if (ret) {
@@ -5311,6 +5340,8 @@ static int hns3_client_init(struct hnae3_handle *handle) · 198 unmodified lines
53115340 priv->ae_handle = handle;
53125341 priv->tx_timeout_count = 0;
53135342 priv->max_non_tso_bd_num = ae_dev->dev_specs.max_non_tso_bd_num;
5343+ priv->min_tx_copybreak = 0;
5344+ priv->min_tx_spare_buf_size = 0;
53145345 set_bit(HNS3_NIC_STATE_DOWN, &priv->state);
53155346
53165347 handle->msg_enable = netif_msg_init(debug, DEFAULT_MSG_LEVEL);
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h+2−0
@@ -596,6 +596,8 @@ struct hns3_nic_priv { · 595 unmodified lines
596596 struct hns3_enet_coalesce rx_coal;
597597 u32 tx_copybreak;
598598 u32 rx_copybreak;
599+ u32 min_tx_copybreak;
600+ u32 min_tx_spare_buf_size;
599601 };
600602
601603 union l3_hdr_info {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t