Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'hns3-next'

Huazhong Tan says:

====================
net: hns3: updates for -next

There are some misc updates for the HNS3 ethernet driver.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+157 -37
+3
drivers/net/ethernet/hisilicon/hns3/hnae3.h
··· 130 130 #define hnae3_dev_stash_supported(hdev) \ 131 131 test_bit(HNAE3_DEV_SUPPORT_STASH_B, (hdev)->ae_dev->caps) 132 132 133 + #define hnae3_ae_dev_tqp_txrx_indep_supported(ae_dev) \ 134 + test_bit(HNAE3_DEV_SUPPORT_TQP_TXRX_INDEP_B, (ae_dev)->caps) 135 + 133 136 #define ring_ptr_move_fw(ring, p) \ 134 137 ((ring)->p = ((ring)->p + 1) % (ring)->desc_num) 135 138 #define ring_ptr_move_bw(ring, p) \
+48 -2
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
··· 15 15 static int hns3_dbg_queue_info(struct hnae3_handle *h, 16 16 const char *cmd_buf) 17 17 { 18 + struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); 18 19 struct hns3_nic_priv *priv = h->priv; 19 20 struct hns3_enet_ring *ring; 20 21 u32 base_add_l, base_add_h; ··· 119 118 120 119 value = readl_relaxed(ring->tqp->io_base + 121 120 HNS3_RING_TX_RING_PKTNUM_RECORD_REG); 122 - dev_info(&h->pdev->dev, "TX(%u) RING PKTNUM: %u\n\n", i, 123 - value); 121 + dev_info(&h->pdev->dev, "TX(%u) RING PKTNUM: %u\n", i, value); 122 + 123 + value = readl_relaxed(ring->tqp->io_base + HNS3_RING_EN_REG); 124 + dev_info(&h->pdev->dev, "TX/RX(%u) RING EN: %s\n", i, 125 + value ? "enable" : "disable"); 126 + 127 + if (hnae3_ae_dev_tqp_txrx_indep_supported(ae_dev)) { 128 + value = readl_relaxed(ring->tqp->io_base + 129 + HNS3_RING_TX_EN_REG); 130 + dev_info(&h->pdev->dev, "TX(%u) RING EN: %s\n", i, 131 + value ? "enable" : "disable"); 132 + 133 + value = readl_relaxed(ring->tqp->io_base + 134 + HNS3_RING_RX_EN_REG); 135 + dev_info(&h->pdev->dev, "RX(%u) RING EN: %s\n", i, 136 + value ? "enable" : "disable"); 137 + } 138 + 139 + dev_info(&h->pdev->dev, "\n"); 124 140 } 125 141 126 142 return 0; ··· 263 245 dev_info(&h->pdev->dev, "queue map\n"); 264 246 dev_info(&h->pdev->dev, "bd info <q_num> <bd index>\n"); 265 247 dev_info(&h->pdev->dev, "dev capability\n"); 248 + dev_info(&h->pdev->dev, "dev spec\n"); 266 249 267 250 if (!hns3_is_phys_func(h->pdev)) 268 251 return; ··· 324 305 test_bit(HNAE3_DEV_SUPPORT_PTP_B, caps) ? "yes" : "no"); 325 306 dev_info(&h->pdev->dev, "support INT QL: %s\n", 326 307 test_bit(HNAE3_DEV_SUPPORT_INT_QL_B, caps) ? "yes" : "no"); 308 + } 309 + 310 + static void hns3_dbg_dev_specs(struct hnae3_handle *h) 311 + { 312 + struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); 313 + struct hnae3_dev_specs *dev_specs = &ae_dev->dev_specs; 314 + struct hnae3_knic_private_info *kinfo = &h->kinfo; 315 + struct hns3_nic_priv *priv = h->priv; 316 + 317 + dev_info(priv->dev, "MAC entry num: %u\n", dev_specs->mac_entry_num); 318 + dev_info(priv->dev, "MNG entry num: %u\n", dev_specs->mng_entry_num); 319 + dev_info(priv->dev, "MAX non tso bd num: %u\n", 320 + dev_specs->max_non_tso_bd_num); 321 + dev_info(priv->dev, "RSS ind tbl size: %u\n", 322 + dev_specs->rss_ind_tbl_size); 323 + dev_info(priv->dev, "RSS key size: %u\n", dev_specs->rss_key_size); 324 + dev_info(priv->dev, "RSS size: %u\n", kinfo->rss_size); 325 + dev_info(priv->dev, "Allocated RSS size: %u\n", kinfo->req_rss_size); 326 + dev_info(priv->dev, "Task queue pairs numbers: %u\n", kinfo->num_tqps); 327 + 328 + dev_info(priv->dev, "RX buffer length: %u\n", kinfo->rx_buf_len); 329 + dev_info(priv->dev, "Desc num per TX queue: %u\n", kinfo->num_tx_desc); 330 + dev_info(priv->dev, "Desc num per RX queue: %u\n", kinfo->num_rx_desc); 331 + dev_info(priv->dev, "Total number of enabled TCs: %u\n", kinfo->num_tc); 332 + dev_info(priv->dev, "MAX INT QL: %u\n", dev_specs->int_ql_max); 327 333 } 328 334 329 335 static ssize_t hns3_dbg_cmd_read(struct file *filp, char __user *buffer, ··· 428 384 ret = hns3_dbg_bd_info(handle, cmd_buf); 429 385 else if (strncmp(cmd_buf, "dev capability", 14) == 0) 430 386 hns3_dbg_dev_caps(handle); 387 + else if (strncmp(cmd_buf, "dev spec", 8) == 0) 388 + hns3_dbg_dev_specs(handle); 431 389 else if (handle->ae_algo->ops->dbg_run_cmd) 432 390 ret = handle->ae_algo->ops->dbg_run_cmd(handle, cmd_buf); 433 391 else
+47 -24
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
··· 696 696 697 697 /* normal or tunnel packet */ 698 698 l4_offset = l4.hdr - skb->data; 699 - hdr_len = (l4.tcp->doff << 2) + l4_offset; 700 699 701 700 /* remove payload length from inner pseudo checksum when tso */ 702 701 l4_paylen = skb->len - l4_offset; 703 - csum_replace_by_diff(&l4.tcp->check, 704 - (__force __wsum)htonl(l4_paylen)); 702 + 703 + if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) { 704 + hdr_len = sizeof(*l4.udp) + l4_offset; 705 + csum_replace_by_diff(&l4.udp->check, 706 + (__force __wsum)htonl(l4_paylen)); 707 + } else { 708 + hdr_len = (l4.tcp->doff << 2) + l4_offset; 709 + csum_replace_by_diff(&l4.tcp->check, 710 + (__force __wsum)htonl(l4_paylen)); 711 + } 705 712 706 713 /* find the txbd field values */ 707 714 *paylen = skb->len - hdr_len; ··· 1191 1184 return bd_num; 1192 1185 } 1193 1186 1194 - static unsigned int hns3_tx_bd_num(struct sk_buff *skb, unsigned int *bd_size) 1187 + static unsigned int hns3_tx_bd_num(struct sk_buff *skb, unsigned int *bd_size, 1188 + u8 max_non_tso_bd_num) 1195 1189 { 1196 1190 struct sk_buff *frag_skb; 1197 1191 unsigned int bd_num = 0; 1198 1192 1199 1193 /* If the total len is within the max bd limit */ 1200 1194 if (likely(skb->len <= HNS3_MAX_BD_SIZE && !skb_has_frag_list(skb) && 1201 - skb_shinfo(skb)->nr_frags < HNS3_MAX_NON_TSO_BD_NUM)) 1195 + skb_shinfo(skb)->nr_frags < max_non_tso_bd_num)) 1202 1196 return skb_shinfo(skb)->nr_frags + 1U; 1203 1197 1204 1198 /* The below case will always be linearized, return 1205 1199 * HNS3_MAX_BD_NUM_TSO + 1U to make sure it is linearized. 1206 1200 */ 1207 1201 if (unlikely(skb->len > HNS3_MAX_TSO_SIZE || 1208 - (!skb_is_gso(skb) && skb->len > HNS3_MAX_NON_TSO_SIZE))) 1202 + (!skb_is_gso(skb) && skb->len > 1203 + HNS3_MAX_NON_TSO_SIZE(max_non_tso_bd_num)))) 1209 1204 return HNS3_MAX_TSO_BD_NUM + 1U; 1210 1205 1211 1206 bd_num = hns3_skb_bd_num(skb, bd_size, bd_num); ··· 1232 1223 return skb_inner_transport_offset(skb) + inner_tcp_hdrlen(skb); 1233 1224 } 1234 1225 1235 - /* HW need every continuous 8 buffer data to be larger than MSS, 1236 - * we simplify it by ensuring skb_headlen + the first continuous 1237 - * 7 frags to to be larger than gso header len + mss, and the remaining 1238 - * continuous 7 frags to be larger than MSS except the last 7 frags. 1226 + /* HW need every continuous max_non_tso_bd_num buffer data to be larger 1227 + * than MSS, we simplify it by ensuring skb_headlen + the first continuous 1228 + * max_non_tso_bd_num - 1 frags to be larger than gso header len + mss, 1229 + * and the remaining continuous max_non_tso_bd_num - 1 frags to be larger 1230 + * than MSS except the last max_non_tso_bd_num - 1 frags. 1239 1231 */ 1240 1232 static bool hns3_skb_need_linearized(struct sk_buff *skb, unsigned int *bd_size, 1241 - unsigned int bd_num) 1233 + unsigned int bd_num, u8 max_non_tso_bd_num) 1242 1234 { 1243 1235 unsigned int tot_len = 0; 1244 1236 int i; 1245 1237 1246 - for (i = 0; i < HNS3_MAX_NON_TSO_BD_NUM - 1U; i++) 1238 + for (i = 0; i < max_non_tso_bd_num - 1U; i++) 1247 1239 tot_len += bd_size[i]; 1248 1240 1249 - /* ensure the first 8 frags is greater than mss + header */ 1250 - if (tot_len + bd_size[HNS3_MAX_NON_TSO_BD_NUM - 1U] < 1241 + /* ensure the first max_non_tso_bd_num frags is greater than 1242 + * mss + header 1243 + */ 1244 + if (tot_len + bd_size[max_non_tso_bd_num - 1U] < 1251 1245 skb_shinfo(skb)->gso_size + hns3_gso_hdr_len(skb)) 1252 1246 return true; 1253 1247 1254 - /* ensure every continuous 7 buffer is greater than mss 1255 - * except the last one. 1248 + /* ensure every continuous max_non_tso_bd_num - 1 buffer is greater 1249 + * than mss except the last one. 1256 1250 */ 1257 - for (i = 0; i < bd_num - HNS3_MAX_NON_TSO_BD_NUM; i++) { 1251 + for (i = 0; i < bd_num - max_non_tso_bd_num; i++) { 1258 1252 tot_len -= bd_size[i]; 1259 - tot_len += bd_size[i + HNS3_MAX_NON_TSO_BD_NUM - 1U]; 1253 + tot_len += bd_size[i + max_non_tso_bd_num - 1U]; 1260 1254 1261 1255 if (tot_len < skb_shinfo(skb)->gso_size) 1262 1256 return true; ··· 1281 1269 struct sk_buff *skb) 1282 1270 { 1283 1271 struct hns3_nic_priv *priv = netdev_priv(netdev); 1272 + u8 max_non_tso_bd_num = priv->max_non_tso_bd_num; 1284 1273 unsigned int bd_size[HNS3_MAX_TSO_BD_NUM + 1U]; 1285 1274 unsigned int bd_num; 1286 1275 1287 - bd_num = hns3_tx_bd_num(skb, bd_size); 1288 - if (unlikely(bd_num > HNS3_MAX_NON_TSO_BD_NUM)) { 1276 + bd_num = hns3_tx_bd_num(skb, bd_size, max_non_tso_bd_num); 1277 + if (unlikely(bd_num > max_non_tso_bd_num)) { 1289 1278 if (bd_num <= HNS3_MAX_TSO_BD_NUM && skb_is_gso(skb) && 1290 - !hns3_skb_need_linearized(skb, bd_size, bd_num)) { 1291 - trace_hns3_over_8bd(skb); 1279 + !hns3_skb_need_linearized(skb, bd_size, bd_num, 1280 + max_non_tso_bd_num)) { 1281 + trace_hns3_over_max_bd(skb); 1292 1282 goto out; 1293 1283 } 1294 1284 ··· 1300 1286 bd_num = hns3_tx_bd_count(skb->len); 1301 1287 if ((skb_is_gso(skb) && bd_num > HNS3_MAX_TSO_BD_NUM) || 1302 1288 (!skb_is_gso(skb) && 1303 - bd_num > HNS3_MAX_NON_TSO_BD_NUM)) { 1304 - trace_hns3_over_8bd(skb); 1289 + bd_num > max_non_tso_bd_num)) { 1290 + trace_hns3_over_max_bd(skb); 1305 1291 return -ENOMEM; 1306 1292 } 1307 1293 ··· 2317 2303 netdev->hw_features |= NETIF_F_NTUPLE; 2318 2304 netdev->features |= NETIF_F_NTUPLE; 2319 2305 } 2306 + } 2307 + 2308 + if (test_bit(HNAE3_DEV_SUPPORT_UDP_GSO_B, ae_dev->caps)) { 2309 + netdev->hw_features |= NETIF_F_GSO_UDP_L4; 2310 + netdev->features |= NETIF_F_GSO_UDP_L4; 2311 + netdev->vlan_features |= NETIF_F_GSO_UDP_L4; 2312 + netdev->hw_enc_features |= NETIF_F_GSO_UDP_L4; 2320 2313 } 2321 2314 } 2322 2315 ··· 4012 3991 static int hns3_client_init(struct hnae3_handle *handle) 4013 3992 { 4014 3993 struct pci_dev *pdev = handle->pdev; 3994 + struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev); 4015 3995 u16 alloc_tqps, max_rss_size; 4016 3996 struct hns3_nic_priv *priv; 4017 3997 struct net_device *netdev; ··· 4029 4007 priv->netdev = netdev; 4030 4008 priv->ae_handle = handle; 4031 4009 priv->tx_timeout_count = 0; 4010 + priv->max_non_tso_bd_num = ae_dev->dev_specs.max_non_tso_bd_num; 4032 4011 set_bit(HNS3_NIC_STATE_DOWN, &priv->state); 4033 4012 4034 4013 handle->msg_enable = netif_msg_init(debug, DEFAULT_MSG_LEVEL);
+5 -3
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
··· 43 43 #define HNS3_RING_TX_RING_EBD_OFFSET_REG 0x00070 44 44 #define HNS3_RING_TX_RING_BD_ERR_REG 0x00074 45 45 #define HNS3_RING_EN_REG 0x00090 46 + #define HNS3_RING_RX_EN_REG 0x00098 47 + #define HNS3_RING_TX_EN_REG 0x000D4 46 48 47 49 #define HNS3_RX_HEAD_SIZE 256 48 50 ··· 169 167 #define HNS3_VECTOR_INITED 1 170 168 171 169 #define HNS3_MAX_BD_SIZE 65535 172 - #define HNS3_MAX_NON_TSO_BD_NUM 8U 173 170 #define HNS3_MAX_TSO_BD_NUM 63U 174 171 #define HNS3_MAX_TSO_SIZE \ 175 172 (HNS3_MAX_BD_SIZE * HNS3_MAX_TSO_BD_NUM) 176 173 177 - #define HNS3_MAX_NON_TSO_SIZE \ 178 - (HNS3_MAX_BD_SIZE * HNS3_MAX_NON_TSO_BD_NUM) 174 + #define HNS3_MAX_NON_TSO_SIZE(max_non_tso_bd_num) \ 175 + (HNS3_MAX_BD_SIZE * (max_non_tso_bd_num)) 179 176 180 177 #define HNS3_VECTOR_GL0_OFFSET 0x100 181 178 #define HNS3_VECTOR_GL1_OFFSET 0x200 ··· 476 475 struct hns3_enet_ring *ring; 477 476 struct hns3_enet_tqp_vector *tqp_vector; 478 477 u16 vector_num; 478 + u8 max_non_tso_bd_num; 479 479 480 480 u64 tx_timeout_count; 481 481
+2 -7
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
··· 311 311 struct hnae3_handle *h = priv->ae_handle; 312 312 int st_param[HNS3_SELF_TEST_TYPE_NUM][2]; 313 313 bool if_running = netif_running(ndev); 314 - #if IS_ENABLED(CONFIG_VLAN_8021Q) 315 - bool dis_vlan_filter; 316 - #endif 317 314 int test_index = 0; 318 315 u32 i; 319 316 ··· 347 350 348 351 #if IS_ENABLED(CONFIG_VLAN_8021Q) 349 352 /* Disable the vlan filter for selftest does not support it */ 350 - dis_vlan_filter = (ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER) && 351 - h->ae_algo->ops->enable_vlan_filter; 352 - if (dis_vlan_filter) 353 + if (h->ae_algo->ops->enable_vlan_filter) 353 354 h->ae_algo->ops->enable_vlan_filter(h, false); 354 355 #endif 355 356 ··· 384 389 h->ae_algo->ops->halt_autoneg(h, false); 385 390 386 391 #if IS_ENABLED(CONFIG_VLAN_8021Q) 387 - if (dis_vlan_filter) 392 + if (h->ae_algo->ops->enable_vlan_filter) 388 393 h->ae_algo->ops->enable_vlan_filter(h, true); 389 394 #endif 390 395
+1 -1
drivers/net/ethernet/hisilicon/hns3/hns3_trace.h
··· 53 53 ) 54 54 ); 55 55 56 - DEFINE_EVENT(hns3_skb_template, hns3_over_8bd, 56 + DEFINE_EVENT(hns3_skb_template, hns3_over_max_bd, 57 57 TP_PROTO(struct sk_buff *skb), 58 58 TP_ARGS(skb)); 59 59
+50
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
··· 1702 1702 return ret; 1703 1703 } 1704 1704 1705 + static int hclgevf_notify_roce_client(struct hclgevf_dev *hdev, 1706 + enum hnae3_reset_notify_type type) 1707 + { 1708 + struct hnae3_client *client = hdev->roce_client; 1709 + struct hnae3_handle *handle = &hdev->roce; 1710 + int ret; 1711 + 1712 + if (!test_bit(HCLGEVF_STATE_ROCE_REGISTERED, &hdev->state) || !client) 1713 + return 0; 1714 + 1715 + if (!client->ops->reset_notify) 1716 + return -EOPNOTSUPP; 1717 + 1718 + ret = client->ops->reset_notify(handle, type); 1719 + if (ret) 1720 + dev_err(&hdev->pdev->dev, "notify roce client failed %d(%d)", 1721 + type, ret); 1722 + return ret; 1723 + } 1724 + 1705 1725 static int hclgevf_reset_wait(struct hclgevf_dev *hdev) 1706 1726 { 1707 1727 #define HCLGEVF_RESET_WAIT_US 20000 ··· 1885 1865 1886 1866 hdev->rst_stats.rst_cnt++; 1887 1867 1868 + /* perform reset of the stack & ae device for a client */ 1869 + ret = hclgevf_notify_roce_client(hdev, HNAE3_DOWN_CLIENT); 1870 + if (ret) 1871 + return ret; 1872 + 1888 1873 rtnl_lock(); 1889 1874 /* bring down the nic to stop any ongoing TX/RX */ 1890 1875 ret = hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT); ··· 1905 1880 int ret; 1906 1881 1907 1882 hdev->rst_stats.hw_rst_done_cnt++; 1883 + ret = hclgevf_notify_roce_client(hdev, HNAE3_UNINIT_CLIENT); 1884 + if (ret) 1885 + return ret; 1908 1886 1909 1887 rtnl_lock(); 1910 1888 /* now, re-initialize the nic client and ae device */ ··· 1917 1889 dev_err(&hdev->pdev->dev, "failed to reset VF stack\n"); 1918 1890 return ret; 1919 1891 } 1892 + 1893 + ret = hclgevf_notify_roce_client(hdev, HNAE3_INIT_CLIENT); 1894 + /* ignore RoCE notify error if it fails HCLGEVF_RESET_MAX_FAIL_CNT - 1 1895 + * times 1896 + */ 1897 + if (ret && 1898 + hdev->rst_stats.rst_fail_cnt < HCLGEVF_RESET_MAX_FAIL_CNT - 1) 1899 + return ret; 1900 + 1901 + ret = hclgevf_notify_roce_client(hdev, HNAE3_UP_CLIENT); 1902 + if (ret) 1903 + return ret; 1920 1904 1921 1905 hdev->last_reset_time = jiffies; 1922 1906 hdev->rst_stats.rst_done_cnt++; ··· 2797 2757 if (ret) 2798 2758 return ret; 2799 2759 2760 + set_bit(HCLGEVF_STATE_ROCE_REGISTERED, &hdev->state); 2800 2761 hnae3_set_client_init_flag(client, ae_dev, 1); 2801 2762 2802 2763 return 0; ··· 2858 2817 2859 2818 /* un-init roce, if it exists */ 2860 2819 if (hdev->roce_client) { 2820 + clear_bit(HCLGEVF_STATE_ROCE_REGISTERED, &hdev->state); 2861 2821 hdev->roce_client->ops->uninit_instance(&hdev->roce, 0); 2862 2822 hdev->roce_client = NULL; 2863 2823 hdev->roce.client = NULL; ··· 3461 3419 return !!hclgevf_read_dev(&hdev->hw, HCLGEVF_RST_ING); 3462 3420 } 3463 3421 3422 + static bool hclgevf_get_cmdq_stat(struct hnae3_handle *handle) 3423 + { 3424 + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); 3425 + 3426 + return test_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state); 3427 + } 3428 + 3464 3429 static bool hclgevf_ae_dev_resetting(struct hnae3_handle *handle) 3465 3430 { 3466 3431 struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); ··· 3653 3604 .get_link_mode = hclgevf_get_link_mode, 3654 3605 .set_promisc_mode = hclgevf_set_promisc_mode, 3655 3606 .request_update_promisc_mode = hclgevf_request_update_promisc_mode, 3607 + .get_cmdq_stat = hclgevf_get_cmdq_stat, 3656 3608 }; 3657 3609 3658 3610 static struct hnae3_ae_algo ae_algovf = {
+1
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h
··· 139 139 HCLGEVF_STATE_IRQ_INITED, 140 140 HCLGEVF_STATE_REMOVING, 141 141 HCLGEVF_STATE_NIC_REGISTERED, 142 + HCLGEVF_STATE_ROCE_REGISTERED, 142 143 /* task states */ 143 144 HCLGEVF_STATE_RST_SERVICE_SCHED, 144 145 HCLGEVF_STATE_RST_HANDLING,