|
11 | 11 | #include <linux/irq.h>
|
12 | 12 | #include <linux/ip.h>
|
13 | 13 | #include <linux/ipv6.h>
|
| 14 | +#include <linux/iommu.h> |
14 | 15 | #include <linux/module.h>
|
15 | 16 | #include <linux/pci.h>
|
16 | 17 | #include <linux/skbuff.h>
|
@@ -1039,6 +1040,8 @@ static bool hns3_can_use_tx_sgl(struct hns3_enet_ring *ring,
|
1039 | 1040 | static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring)
|
1040 | 1041 | {
|
1041 | 1042 | 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); |
1042 | 1045 | struct hns3_tx_spare *tx_spare;
|
1043 | 1046 | struct page *page;
|
1044 | 1047 | dma_addr_t dma;
|
@@ -1080,6 +1083,7 @@ static void hns3_init_tx_spare_buffer(struct hns3_enet_ring *ring)
|
1080 | 1083 | tx_spare->buf = page_address(page);
|
1081 | 1084 | tx_spare->len = PAGE_SIZE << order;
|
1082 | 1085 | ring->tx_spare = tx_spare;
|
| 1086 | + ring->tx_copybreak = priv->tx_copybreak; |
1083 | 1087 | return;
|
1084 | 1088 |
|
1085 | 1089 | dma_mapping_error:
|
@@ -4874,6 +4878,30 @@ static void hns3_nic_dealloc_vector_data(struct hns3_nic_priv *priv)
|
4874 | 4878 | devm_kfree(&pdev->dev, priv->tqp_vector);
|
4875 | 4879 | }
|
4876 | 4880 |
|
| 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 | + |
4877 | 4905 | static void hns3_ring_get_cfg(struct hnae3_queue *q, struct hns3_nic_priv *priv,
|
4878 | 4906 | unsigned int ring_type)
|
4879 | 4907 | {
|
@@ -5107,6 +5135,7 @@ int hns3_init_all_ring(struct hns3_nic_priv *priv)
|
5107 | 5135 | int i, j;
|
5108 | 5136 | int ret;
|
5109 | 5137 |
|
| 5138 | + hns3_update_tx_spare_buf_config(priv); |
5110 | 5139 | for (i = 0; i < ring_num; i++) {
|
5111 | 5140 | ret = hns3_alloc_ring_memory(&priv->ring[i]);
|
5112 | 5141 | if (ret) {
|
@@ -5311,6 +5340,8 @@ static int hns3_client_init(struct hnae3_handle *handle)
|
5311 | 5340 | priv->ae_handle = handle;
|
5312 | 5341 | priv->tx_timeout_count = 0;
|
5313 | 5342 | 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; |
5314 | 5345 | set_bit(HNS3_NIC_STATE_DOWN, &priv->state);
|
5315 | 5346 |
|
5316 | 5347 | handle->msg_enable = netif_msg_init(debug, DEFAULT_MSG_LEVEL);
|
|
0 commit comments