.. | .. |
---|
1 | | -// SPDX-License-Identifier: GPL-2.0+ |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0+ */ |
---|
2 | 2 | // Copyright (c) 2016-2017 Hisilicon Limited. |
---|
3 | 3 | |
---|
4 | 4 | #ifndef __HNS3_ENET_H |
---|
.. | .. |
---|
8 | 8 | |
---|
9 | 9 | #include "hnae3.h" |
---|
10 | 10 | |
---|
11 | | -#define HNS3_MOD_VERSION "1.0" |
---|
12 | | - |
---|
13 | | -extern const char hns3_driver_version[]; |
---|
14 | | - |
---|
15 | 11 | enum hns3_nic_state { |
---|
16 | 12 | HNS3_NIC_STATE_TESTING, |
---|
17 | 13 | HNS3_NIC_STATE_RESETTING, |
---|
18 | | - HNS3_NIC_STATE_REINITING, |
---|
| 14 | + HNS3_NIC_STATE_INITED, |
---|
19 | 15 | HNS3_NIC_STATE_DOWN, |
---|
20 | 16 | HNS3_NIC_STATE_DISABLED, |
---|
21 | 17 | HNS3_NIC_STATE_REMOVING, |
---|
.. | .. |
---|
42 | 38 | #define HNS3_RING_TX_RING_HEAD_REG 0x0005C |
---|
43 | 39 | #define HNS3_RING_TX_RING_FBDNUM_REG 0x00060 |
---|
44 | 40 | #define HNS3_RING_TX_RING_OFFSET_REG 0x00064 |
---|
| 41 | +#define HNS3_RING_TX_RING_EBDNUM_REG 0x00068 |
---|
45 | 42 | #define HNS3_RING_TX_RING_PKTNUM_RECORD_REG 0x0006C |
---|
46 | | - |
---|
47 | | -#define HNS3_RING_PREFETCH_EN_REG 0x0007C |
---|
48 | | -#define HNS3_RING_CFG_VF_NUM_REG 0x00080 |
---|
49 | | -#define HNS3_RING_ASID_REG 0x0008C |
---|
50 | | -#define HNS3_RING_RX_VM_REG 0x00090 |
---|
51 | | -#define HNS3_RING_T0_BE_RST 0x00094 |
---|
52 | | -#define HNS3_RING_COULD_BE_RST 0x00098 |
---|
53 | | -#define HNS3_RING_WRR_WEIGHT_REG 0x0009c |
---|
54 | | - |
---|
55 | | -#define HNS3_RING_INTMSK_RXWL_REG 0x000A0 |
---|
56 | | -#define HNS3_RING_INTSTS_RX_RING_REG 0x000A4 |
---|
57 | | -#define HNS3_RX_RING_INT_STS_REG 0x000A8 |
---|
58 | | -#define HNS3_RING_INTMSK_TXWL_REG 0x000AC |
---|
59 | | -#define HNS3_RING_INTSTS_TX_RING_REG 0x000B0 |
---|
60 | | -#define HNS3_TX_RING_INT_STS_REG 0x000B4 |
---|
61 | | -#define HNS3_RING_INTMSK_RX_OVERTIME_REG 0x000B8 |
---|
62 | | -#define HNS3_RING_INTSTS_RX_OVERTIME_REG 0x000BC |
---|
63 | | -#define HNS3_RING_INTMSK_TX_OVERTIME_REG 0x000C4 |
---|
64 | | -#define HNS3_RING_INTSTS_TX_OVERTIME_REG 0x000C8 |
---|
65 | | - |
---|
66 | | -#define HNS3_RING_MB_CTRL_REG 0x00100 |
---|
67 | | -#define HNS3_RING_MB_DATA_BASE_REG 0x00200 |
---|
68 | | - |
---|
69 | | -#define HNS3_TX_REG_OFFSET 0x40 |
---|
| 43 | +#define HNS3_RING_TX_RING_EBD_OFFSET_REG 0x00070 |
---|
| 44 | +#define HNS3_RING_TX_RING_BD_ERR_REG 0x00074 |
---|
| 45 | +#define HNS3_RING_EN_REG 0x00090 |
---|
| 46 | +#define HNS3_RING_RX_EN_REG 0x00098 |
---|
| 47 | +#define HNS3_RING_TX_EN_REG 0x000D4 |
---|
70 | 48 | |
---|
71 | 49 | #define HNS3_RX_HEAD_SIZE 256 |
---|
72 | 50 | |
---|
73 | 51 | #define HNS3_TX_TIMEOUT (5 * HZ) |
---|
74 | 52 | #define HNS3_RING_NAME_LEN 16 |
---|
75 | 53 | #define HNS3_BUFFER_SIZE_2048 2048 |
---|
76 | | -#define HNS3_RING_MAX_PENDING 32768 |
---|
77 | | -#define HNS3_RING_MIN_PENDING 8 |
---|
| 54 | +#define HNS3_RING_MAX_PENDING 32760 |
---|
| 55 | +#define HNS3_RING_MIN_PENDING 72 |
---|
78 | 56 | #define HNS3_RING_BD_MULTIPLE 8 |
---|
79 | | -#define HNS3_MAX_MTU 9728 |
---|
| 57 | +/* max frame size of mac */ |
---|
| 58 | +#define HNS3_MAC_MAX_FRAME 9728 |
---|
| 59 | +#define HNS3_MAX_MTU \ |
---|
| 60 | + (HNS3_MAC_MAX_FRAME - (ETH_HLEN + ETH_FCS_LEN + 2 * VLAN_HLEN)) |
---|
80 | 61 | |
---|
81 | 62 | #define HNS3_BD_SIZE_512_TYPE 0 |
---|
82 | 63 | #define HNS3_BD_SIZE_1024_TYPE 1 |
---|
.. | .. |
---|
109 | 90 | #define HNS3_RXD_DOI_B 21 |
---|
110 | 91 | #define HNS3_RXD_OL3E_B 22 |
---|
111 | 92 | #define HNS3_RXD_OL4E_B 23 |
---|
| 93 | +#define HNS3_RXD_GRO_COUNT_S 24 |
---|
| 94 | +#define HNS3_RXD_GRO_COUNT_M (0x3f << HNS3_RXD_GRO_COUNT_S) |
---|
| 95 | +#define HNS3_RXD_GRO_FIXID_B 30 |
---|
| 96 | +#define HNS3_RXD_GRO_ECN_B 31 |
---|
112 | 97 | |
---|
113 | 98 | #define HNS3_RXD_ODMAC_S 0 |
---|
114 | 99 | #define HNS3_RXD_ODMAC_M (0x3 << HNS3_RXD_ODMAC_S) |
---|
.. | .. |
---|
135 | 120 | #define HNS3_RXD_TSIND_S 12 |
---|
136 | 121 | #define HNS3_RXD_TSIND_M (0x7 << HNS3_RXD_TSIND_S) |
---|
137 | 122 | #define HNS3_RXD_LKBK_B 15 |
---|
138 | | -#define HNS3_RXD_HDL_S 16 |
---|
139 | | -#define HNS3_RXD_HDL_M (0x7ff << HNS3_RXD_HDL_S) |
---|
140 | | -#define HNS3_RXD_HSIND_B 31 |
---|
| 123 | +#define HNS3_RXD_GRO_SIZE_S 16 |
---|
| 124 | +#define HNS3_RXD_GRO_SIZE_M (0x3fff << HNS3_RXD_GRO_SIZE_S) |
---|
141 | 125 | |
---|
142 | 126 | #define HNS3_TXD_L3T_S 0 |
---|
143 | 127 | #define HNS3_TXD_L3T_M (0x3 << HNS3_TXD_L3T_S) |
---|
.. | .. |
---|
185 | 169 | #define HNS3_VECTOR_INITED 1 |
---|
186 | 170 | |
---|
187 | 171 | #define HNS3_MAX_BD_SIZE 65535 |
---|
188 | | -#define HNS3_MAX_BD_PER_FRAG 8 |
---|
189 | | -#define HNS3_MAX_BD_PER_PKT MAX_SKB_FRAGS |
---|
| 172 | +#define HNS3_MAX_TSO_BD_NUM 63U |
---|
| 173 | +#define HNS3_MAX_TSO_SIZE 1048576U |
---|
| 174 | +#define HNS3_MAX_NON_TSO_SIZE 9728U |
---|
| 175 | + |
---|
190 | 176 | |
---|
191 | 177 | #define HNS3_VECTOR_GL0_OFFSET 0x100 |
---|
192 | 178 | #define HNS3_VECTOR_GL1_OFFSET 0x200 |
---|
193 | 179 | #define HNS3_VECTOR_GL2_OFFSET 0x300 |
---|
194 | 180 | #define HNS3_VECTOR_RL_OFFSET 0x900 |
---|
195 | 181 | #define HNS3_VECTOR_RL_EN_B 6 |
---|
| 182 | + |
---|
| 183 | +#define HNS3_RING_EN_B 0 |
---|
| 184 | + |
---|
| 185 | +enum hns3_pkt_l2t_type { |
---|
| 186 | + HNS3_L2_TYPE_UNICAST, |
---|
| 187 | + HNS3_L2_TYPE_MULTICAST, |
---|
| 188 | + HNS3_L2_TYPE_BROADCAST, |
---|
| 189 | + HNS3_L2_TYPE_INVALID, |
---|
| 190 | +}; |
---|
196 | 191 | |
---|
197 | 192 | enum hns3_pkt_l3t_type { |
---|
198 | 193 | HNS3_L3T_NONE, |
---|
.. | .. |
---|
282 | 277 | dma_addr_t dma; /* dma address of this desc */ |
---|
283 | 278 | void *buf; /* cpu addr for a desc */ |
---|
284 | 279 | |
---|
285 | | - /* priv data for the desc, e.g. skb when use with ip stack*/ |
---|
| 280 | + /* priv data for the desc, e.g. skb when use with ip stack */ |
---|
286 | 281 | void *priv; |
---|
287 | 282 | u32 page_offset; |
---|
288 | 283 | u32 length; /* length of the buffer */ |
---|
289 | 284 | |
---|
290 | 285 | u16 reuse_flag; |
---|
| 286 | + u16 refill; |
---|
291 | 287 | |
---|
292 | | - /* desc type, used by the ring user to mark the type of the priv data */ |
---|
| 288 | + /* desc type, used by the ring user to mark the type of the priv data */ |
---|
293 | 289 | u16 type; |
---|
| 290 | + u16 pagecnt_bias; |
---|
294 | 291 | }; |
---|
295 | 292 | |
---|
296 | 293 | enum hns3_pkt_l3type { |
---|
.. | .. |
---|
305 | 302 | HNS3_L3_TYPE_MAC_PAUSE, |
---|
306 | 303 | HNS3_L3_TYPE_PFC_PAUSE,/* 0x9*/ |
---|
307 | 304 | |
---|
308 | | - /* reserved for 0xA~0xB*/ |
---|
| 305 | + /* reserved for 0xA~0xB */ |
---|
309 | 306 | |
---|
310 | 307 | HNS3_L3_TYPE_CNM = 0xc, |
---|
311 | 308 | |
---|
312 | | - /* reserved for 0xD~0xE*/ |
---|
| 309 | + /* reserved for 0xD~0xE */ |
---|
313 | 310 | |
---|
314 | 311 | HNS3_L3_TYPE_PARSE_FAIL = 0xf /* must be last */ |
---|
315 | 312 | }; |
---|
.. | .. |
---|
334 | 331 | HNS3_OL3_TYPE_IPV4_OPT = 4, |
---|
335 | 332 | HNS3_OL3_TYPE_IPV6_EXT, |
---|
336 | 333 | |
---|
337 | | - /* reserved for 0x6~0xE*/ |
---|
| 334 | + /* reserved for 0x6~0xE */ |
---|
338 | 335 | |
---|
339 | 336 | HNS3_OL3_TYPE_PARSE_FAIL = 0xf /* must be last */ |
---|
340 | 337 | }; |
---|
.. | .. |
---|
347 | 344 | }; |
---|
348 | 345 | |
---|
349 | 346 | struct ring_stats { |
---|
350 | | - u64 io_err_cnt; |
---|
351 | 347 | u64 sw_err_cnt; |
---|
352 | 348 | u64 seg_pkt_cnt; |
---|
353 | 349 | union { |
---|
354 | 350 | struct { |
---|
355 | 351 | u64 tx_pkts; |
---|
356 | 352 | u64 tx_bytes; |
---|
357 | | - u64 tx_err_cnt; |
---|
| 353 | + u64 tx_more; |
---|
358 | 354 | u64 restart_queue; |
---|
359 | 355 | u64 tx_busy; |
---|
| 356 | + u64 tx_copy; |
---|
| 357 | + u64 tx_vlan_err; |
---|
| 358 | + u64 tx_l4_proto_err; |
---|
| 359 | + u64 tx_l2l3l4_err; |
---|
| 360 | + u64 tx_tso_err; |
---|
| 361 | + u64 over_max_recursion; |
---|
| 362 | + u64 hw_limitation; |
---|
360 | 363 | }; |
---|
361 | 364 | struct { |
---|
362 | 365 | u64 rx_pkts; |
---|
.. | .. |
---|
364 | 367 | u64 rx_err_cnt; |
---|
365 | 368 | u64 reuse_pg_cnt; |
---|
366 | 369 | u64 err_pkt_len; |
---|
367 | | - u64 non_vld_descs; |
---|
368 | 370 | u64 err_bd_num; |
---|
369 | 371 | u64 l2_err; |
---|
370 | 372 | u64 l3l4_csum_err; |
---|
| 373 | + u64 rx_multicast; |
---|
| 374 | + u64 non_reuse_pg; |
---|
371 | 375 | }; |
---|
372 | 376 | }; |
---|
373 | 377 | }; |
---|
374 | 378 | |
---|
375 | 379 | struct hns3_enet_ring { |
---|
376 | | - u8 __iomem *io_base; /* base io address for the ring */ |
---|
377 | 380 | struct hns3_desc *desc; /* dma map address space */ |
---|
378 | 381 | struct hns3_desc_cb *desc_cb; |
---|
379 | 382 | struct hns3_enet_ring *next; |
---|
380 | 383 | struct hns3_enet_tqp_vector *tqp_vector; |
---|
381 | 384 | struct hnae3_queue *tqp; |
---|
382 | | - char ring_name[HNS3_RING_NAME_LEN]; |
---|
| 385 | + int queue_index; |
---|
383 | 386 | struct device *dev; /* will be used for DMA mapping of descriptors */ |
---|
384 | 387 | |
---|
385 | 388 | /* statistic */ |
---|
.. | .. |
---|
389 | 392 | dma_addr_t desc_dma_addr; |
---|
390 | 393 | u32 buf_size; /* size for hnae_desc->addr, preset by AE */ |
---|
391 | 394 | u16 desc_num; /* total number of desc */ |
---|
392 | | - u16 max_desc_num_per_pkt; |
---|
393 | | - u16 max_raw_data_sz_per_desc; |
---|
394 | | - u16 max_pkt_size; |
---|
395 | 395 | int next_to_use; /* idx of next spare desc */ |
---|
396 | 396 | |
---|
397 | 397 | /* idx of lastest sent desc, the ring is empty when equal to |
---|
398 | 398 | * next_to_use |
---|
399 | 399 | */ |
---|
400 | 400 | int next_to_clean; |
---|
| 401 | + union { |
---|
| 402 | + int last_to_use; /* last idx used by xmit */ |
---|
| 403 | + u32 pull_len; /* memcpy len for current rx packet */ |
---|
| 404 | + }; |
---|
| 405 | + u32 frag_num; |
---|
| 406 | + void *va; /* first buffer address for current packet */ |
---|
401 | 407 | |
---|
402 | 408 | u32 flag; /* ring attribute */ |
---|
403 | | - int irq_init_flag; |
---|
404 | 409 | |
---|
405 | | - int numa_node; |
---|
406 | | - cpumask_t affinity_mask; |
---|
407 | | -}; |
---|
408 | | - |
---|
409 | | -struct hns_queue; |
---|
410 | | - |
---|
411 | | -struct hns3_nic_ring_data { |
---|
412 | | - struct hns3_enet_ring *ring; |
---|
413 | | - struct napi_struct napi; |
---|
414 | | - int queue_index; |
---|
415 | | - int (*poll_one)(struct hns3_nic_ring_data *, int, void *); |
---|
416 | | - void (*ex_process)(struct hns3_nic_ring_data *, struct sk_buff *); |
---|
417 | | - void (*fini_process)(struct hns3_nic_ring_data *); |
---|
418 | | -}; |
---|
419 | | - |
---|
420 | | -struct hns3_nic_ops { |
---|
421 | | - int (*fill_desc)(struct hns3_enet_ring *ring, void *priv, |
---|
422 | | - int size, dma_addr_t dma, int frag_end, |
---|
423 | | - enum hns_desc_type type); |
---|
424 | | - int (*maybe_stop_tx)(struct sk_buff **out_skb, |
---|
425 | | - int *bnum, struct hns3_enet_ring *ring); |
---|
426 | | - void (*get_rxd_bnum)(u32 bnum_flag, int *out_bnum); |
---|
427 | | -}; |
---|
| 410 | + int pending_buf; |
---|
| 411 | + struct sk_buff *skb; |
---|
| 412 | + struct sk_buff *tail_skb; |
---|
| 413 | +} ____cacheline_internodealigned_in_smp; |
---|
428 | 414 | |
---|
429 | 415 | enum hns3_flow_level_range { |
---|
430 | 416 | HNS3_FLOW_LOW = 0, |
---|
431 | 417 | HNS3_FLOW_MID = 1, |
---|
432 | 418 | HNS3_FLOW_HIGH = 2, |
---|
433 | 419 | HNS3_FLOW_ULTRA = 3, |
---|
434 | | -}; |
---|
435 | | - |
---|
436 | | -enum hns3_link_mode_bits { |
---|
437 | | - HNS3_LM_FIBRE_BIT = BIT(0), |
---|
438 | | - HNS3_LM_AUTONEG_BIT = BIT(1), |
---|
439 | | - HNS3_LM_TP_BIT = BIT(2), |
---|
440 | | - HNS3_LM_PAUSE_BIT = BIT(3), |
---|
441 | | - HNS3_LM_BACKPLANE_BIT = BIT(4), |
---|
442 | | - HNS3_LM_10BASET_HALF_BIT = BIT(5), |
---|
443 | | - HNS3_LM_10BASET_FULL_BIT = BIT(6), |
---|
444 | | - HNS3_LM_100BASET_HALF_BIT = BIT(7), |
---|
445 | | - HNS3_LM_100BASET_FULL_BIT = BIT(8), |
---|
446 | | - HNS3_LM_1000BASET_FULL_BIT = BIT(9), |
---|
447 | | - HNS3_LM_10000BASEKR_FULL_BIT = BIT(10), |
---|
448 | | - HNS3_LM_25000BASEKR_FULL_BIT = BIT(11), |
---|
449 | | - HNS3_LM_40000BASELR4_FULL_BIT = BIT(12), |
---|
450 | | - HNS3_LM_50000BASEKR2_FULL_BIT = BIT(13), |
---|
451 | | - HNS3_LM_100000BASEKR4_FULL_BIT = BIT(14), |
---|
452 | | - HNS3_LM_COUNT = 15 |
---|
453 | 420 | }; |
---|
454 | 421 | |
---|
455 | 422 | #define HNS3_INT_GL_MAX 0x1FE0 |
---|
.. | .. |
---|
460 | 427 | |
---|
461 | 428 | #define HNS3_INT_RL_MAX 0x00EC |
---|
462 | 429 | #define HNS3_INT_RL_ENABLE_MASK 0x40 |
---|
463 | | - |
---|
464 | | -#define HNS3_INT_ADAPT_DOWN_START 100 |
---|
465 | 430 | |
---|
466 | 431 | struct hns3_enet_coalesce { |
---|
467 | 432 | u16 int_gl; |
---|
.. | .. |
---|
491 | 456 | struct hns3_enet_ring_group rx_group; |
---|
492 | 457 | struct hns3_enet_ring_group tx_group; |
---|
493 | 458 | |
---|
| 459 | + cpumask_t affinity_mask; |
---|
494 | 460 | u16 num_tqps; /* total number of tqps in TQP vector */ |
---|
| 461 | + struct irq_affinity_notify affinity_notify; |
---|
495 | 462 | |
---|
496 | 463 | char name[HNAE3_INT_NAME_LEN]; |
---|
497 | 464 | |
---|
498 | | - /* when 0 should adjust interrupt coalesce parameter */ |
---|
499 | | - u8 int_adapt_down; |
---|
500 | 465 | unsigned long last_jiffies; |
---|
501 | 466 | } ____cacheline_internodealigned_in_smp; |
---|
502 | 467 | |
---|
503 | | -enum hns3_udp_tnl_type { |
---|
504 | | - HNS3_UDP_TNL_VXLAN, |
---|
505 | | - HNS3_UDP_TNL_GENEVE, |
---|
506 | | - HNS3_UDP_TNL_MAX, |
---|
507 | | -}; |
---|
508 | | - |
---|
509 | | -struct hns3_udp_tunnel { |
---|
510 | | - u16 dst_port; |
---|
511 | | - int used; |
---|
512 | | -}; |
---|
513 | | - |
---|
514 | 468 | struct hns3_nic_priv { |
---|
515 | 469 | struct hnae3_handle *ae_handle; |
---|
516 | | - u32 enet_ver; |
---|
517 | | - u32 port_id; |
---|
518 | 470 | struct net_device *netdev; |
---|
519 | 471 | struct device *dev; |
---|
520 | | - struct hns3_nic_ops ops; |
---|
521 | 472 | |
---|
522 | 473 | /** |
---|
523 | 474 | * the cb for nic to manage the ring buffer, the first half of the |
---|
524 | 475 | * array is for tx_ring and vice versa for the second half |
---|
525 | 476 | */ |
---|
526 | | - struct hns3_nic_ring_data *ring_data; |
---|
| 477 | + struct hns3_enet_ring *ring; |
---|
527 | 478 | struct hns3_enet_tqp_vector *tqp_vector; |
---|
528 | 479 | u16 vector_num; |
---|
| 480 | + u8 max_non_tso_bd_num; |
---|
529 | 481 | |
---|
530 | | - /* The most recently read link state */ |
---|
531 | | - int link; |
---|
532 | 482 | u64 tx_timeout_count; |
---|
533 | 483 | |
---|
534 | 484 | unsigned long state; |
---|
535 | 485 | |
---|
536 | | - struct timer_list service_timer; |
---|
537 | | - |
---|
538 | | - struct work_struct service_task; |
---|
539 | | - |
---|
540 | | - struct notifier_block notifier_block; |
---|
541 | | - /* Vxlan/Geneve information */ |
---|
542 | | - struct hns3_udp_tunnel udp_tnl[HNS3_UDP_TNL_MAX]; |
---|
543 | | - unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; |
---|
544 | 486 | struct hns3_enet_coalesce tx_coal; |
---|
545 | 487 | struct hns3_enet_coalesce rx_coal; |
---|
546 | 488 | }; |
---|
.. | .. |
---|
554 | 496 | union l4_hdr_info { |
---|
555 | 497 | struct tcphdr *tcp; |
---|
556 | 498 | struct udphdr *udp; |
---|
| 499 | + struct gre_base_hdr *gre; |
---|
557 | 500 | unsigned char *hdr; |
---|
558 | 501 | }; |
---|
559 | 502 | |
---|
560 | | -/* the distance between [begin, end) in a ring buffer |
---|
561 | | - * note: there is a unuse slot between the begin and the end |
---|
562 | | - */ |
---|
563 | | -static inline int ring_dist(struct hns3_enet_ring *ring, int begin, int end) |
---|
564 | | -{ |
---|
565 | | - return (end - begin + ring->desc_num) % ring->desc_num; |
---|
566 | | -} |
---|
| 503 | +struct hns3_hw_error_info { |
---|
| 504 | + enum hnae3_hw_error_type type; |
---|
| 505 | + const char *msg; |
---|
| 506 | +}; |
---|
567 | 507 | |
---|
568 | 508 | static inline int ring_space(struct hns3_enet_ring *ring) |
---|
569 | 509 | { |
---|
570 | | - return ring->desc_num - |
---|
571 | | - ring_dist(ring, ring->next_to_clean, ring->next_to_use) - 1; |
---|
| 510 | + /* This smp_load_acquire() pairs with smp_store_release() in |
---|
| 511 | + * hns3_nic_reclaim_one_desc called by hns3_clean_tx_ring. |
---|
| 512 | + */ |
---|
| 513 | + int begin = smp_load_acquire(&ring->next_to_clean); |
---|
| 514 | + int end = READ_ONCE(ring->next_to_use); |
---|
| 515 | + |
---|
| 516 | + return ((end >= begin) ? (ring->desc_num - end + begin) : |
---|
| 517 | + (begin - end)) - 1; |
---|
572 | 518 | } |
---|
573 | 519 | |
---|
574 | | -static inline int is_ring_empty(struct hns3_enet_ring *ring) |
---|
| 520 | +static inline u32 hns3_read_reg(void __iomem *base, u32 reg) |
---|
575 | 521 | { |
---|
576 | | - return ring->next_to_use == ring->next_to_clean; |
---|
| 522 | + return readl(base + reg); |
---|
577 | 523 | } |
---|
578 | 524 | |
---|
579 | 525 | static inline void hns3_write_reg(void __iomem *base, u32 reg, u32 value) |
---|
.. | .. |
---|
583 | 529 | writel(value, reg_addr + reg); |
---|
584 | 530 | } |
---|
585 | 531 | |
---|
| 532 | +#define hns3_read_dev(a, reg) \ |
---|
| 533 | + hns3_read_reg((a)->io_base, (reg)) |
---|
| 534 | + |
---|
| 535 | +static inline bool hns3_nic_resetting(struct net_device *netdev) |
---|
| 536 | +{ |
---|
| 537 | + struct hns3_nic_priv *priv = netdev_priv(netdev); |
---|
| 538 | + |
---|
| 539 | + return test_bit(HNS3_NIC_STATE_RESETTING, &priv->state); |
---|
| 540 | +} |
---|
| 541 | + |
---|
586 | 542 | #define hns3_write_dev(a, reg, value) \ |
---|
587 | 543 | hns3_write_reg((a)->io_base, (reg), (value)) |
---|
588 | 544 | |
---|
589 | | -#define hnae3_queue_xmit(tqp, buf_num) writel_relaxed(buf_num, \ |
---|
590 | | - (tqp)->io_base + HNS3_RING_TX_RING_TAIL_REG) |
---|
| 545 | +#define ring_to_dev(ring) ((ring)->dev) |
---|
591 | 546 | |
---|
592 | | -#define ring_to_dev(ring) (&(ring)->tqp->handle->pdev->dev) |
---|
| 547 | +#define ring_to_netdev(ring) ((ring)->tqp_vector->napi.dev) |
---|
593 | 548 | |
---|
594 | 549 | #define ring_to_dma_dir(ring) (HNAE3_IS_TX_RING(ring) ? \ |
---|
595 | 550 | DMA_TO_DEVICE : DMA_FROM_DEVICE) |
---|
596 | 551 | |
---|
597 | | -#define tx_ring_data(priv, idx) ((priv)->ring_data[idx]) |
---|
| 552 | +#define hns3_buf_size(_ring) ((_ring)->buf_size) |
---|
598 | 553 | |
---|
599 | | -#define hnae3_buf_size(_ring) ((_ring)->buf_size) |
---|
600 | | -#define hnae3_page_order(_ring) (get_order(hnae3_buf_size(_ring))) |
---|
601 | | -#define hnae3_page_size(_ring) (PAGE_SIZE << hnae3_page_order(_ring)) |
---|
| 554 | +static inline unsigned int hns3_page_order(struct hns3_enet_ring *ring) |
---|
| 555 | +{ |
---|
| 556 | +#if (PAGE_SIZE < 8192) |
---|
| 557 | + if (ring->buf_size > (PAGE_SIZE / 2)) |
---|
| 558 | + return 1; |
---|
| 559 | +#endif |
---|
| 560 | + return 0; |
---|
| 561 | +} |
---|
| 562 | + |
---|
| 563 | +#define hns3_page_size(_ring) (PAGE_SIZE << hns3_page_order(_ring)) |
---|
602 | 564 | |
---|
603 | 565 | /* iterator for handling rings in ring group */ |
---|
604 | 566 | #define hns3_for_each_ring(pos, head) \ |
---|
.. | .. |
---|
617 | 579 | int hns3_set_channels(struct net_device *netdev, |
---|
618 | 580 | struct ethtool_channels *ch); |
---|
619 | 581 | |
---|
620 | | -bool hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget); |
---|
| 582 | +void hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget); |
---|
621 | 583 | int hns3_init_all_ring(struct hns3_nic_priv *priv); |
---|
622 | 584 | int hns3_uninit_all_ring(struct hns3_nic_priv *priv); |
---|
623 | 585 | int hns3_nic_reset_all_ring(struct hnae3_handle *h); |
---|
| 586 | +void hns3_fini_ring(struct hns3_enet_ring *ring); |
---|
624 | 587 | netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev); |
---|
| 588 | +bool hns3_is_phys_func(struct pci_dev *pdev); |
---|
625 | 589 | int hns3_clean_rx_ring( |
---|
626 | 590 | struct hns3_enet_ring *ring, int budget, |
---|
627 | 591 | void (*rx_fn)(struct hns3_enet_ring *, struct sk_buff *)); |
---|
.. | .. |
---|
633 | 597 | void hns3_set_vector_coalesce_rl(struct hns3_enet_tqp_vector *tqp_vector, |
---|
634 | 598 | u32 rl_value); |
---|
635 | 599 | |
---|
| 600 | +void hns3_enable_vlan_filter(struct net_device *netdev, bool enable); |
---|
| 601 | +void hns3_request_update_promisc_mode(struct hnae3_handle *handle); |
---|
| 602 | + |
---|
636 | 603 | #ifdef CONFIG_HNS3_DCB |
---|
637 | 604 | void hns3_dcbnl_setup(struct hnae3_handle *handle); |
---|
638 | 605 | #else |
---|
639 | 606 | static inline void hns3_dcbnl_setup(struct hnae3_handle *handle) {} |
---|
640 | 607 | #endif |
---|
641 | 608 | |
---|
| 609 | +void hns3_dbg_init(struct hnae3_handle *handle); |
---|
| 610 | +void hns3_dbg_uninit(struct hnae3_handle *handle); |
---|
| 611 | +void hns3_dbg_register_debugfs(const char *debugfs_dir_name); |
---|
| 612 | +void hns3_dbg_unregister_debugfs(void); |
---|
| 613 | +void hns3_shinfo_pack(struct skb_shared_info *shinfo, __u32 *size); |
---|
642 | 614 | #endif |
---|