.. | .. |
---|
1 | | -/* |
---|
2 | | - * Copyright (C) 2015-2017 Netronome Systems, Inc. |
---|
3 | | - * |
---|
4 | | - * This software is dual licensed under the GNU General License Version 2, |
---|
5 | | - * June 1991 as shown in the file COPYING in the top-level directory of this |
---|
6 | | - * source tree or the BSD 2-Clause License provided below. You have the |
---|
7 | | - * option to license this software under the complete terms of either license. |
---|
8 | | - * |
---|
9 | | - * The BSD 2-Clause License: |
---|
10 | | - * |
---|
11 | | - * Redistribution and use in source and binary forms, with or |
---|
12 | | - * without modification, are permitted provided that the following |
---|
13 | | - * conditions are met: |
---|
14 | | - * |
---|
15 | | - * 1. Redistributions of source code must retain the above |
---|
16 | | - * copyright notice, this list of conditions and the following |
---|
17 | | - * disclaimer. |
---|
18 | | - * |
---|
19 | | - * 2. Redistributions in binary form must reproduce the above |
---|
20 | | - * copyright notice, this list of conditions and the following |
---|
21 | | - * disclaimer in the documentation and/or other materials |
---|
22 | | - * provided with the distribution. |
---|
23 | | - * |
---|
24 | | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
---|
25 | | - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
---|
26 | | - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
---|
27 | | - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
---|
28 | | - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
---|
29 | | - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
---|
30 | | - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
---|
31 | | - * SOFTWARE. |
---|
32 | | - */ |
---|
| 1 | +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ |
---|
| 2 | +/* Copyright (C) 2015-2018 Netronome Systems, Inc. */ |
---|
33 | 3 | |
---|
34 | 4 | /* |
---|
35 | 5 | * nfp_net.h |
---|
.. | .. |
---|
42 | 12 | #ifndef _NFP_NET_H_ |
---|
43 | 13 | #define _NFP_NET_H_ |
---|
44 | 14 | |
---|
| 15 | +#include <linux/atomic.h> |
---|
45 | 16 | #include <linux/interrupt.h> |
---|
46 | 17 | #include <linux/list.h> |
---|
47 | 18 | #include <linux/netdevice.h> |
---|
48 | 19 | #include <linux/pci.h> |
---|
49 | 20 | #include <linux/io-64-nonatomic-hi-lo.h> |
---|
| 21 | +#include <linux/semaphore.h> |
---|
| 22 | +#include <linux/workqueue.h> |
---|
50 | 23 | #include <net/xdp.h> |
---|
51 | 24 | |
---|
52 | 25 | #include "nfp_net_ctrl.h" |
---|
.. | .. |
---|
93 | 66 | #define NFP_NET_MAX_DMA_BITS 40 |
---|
94 | 67 | |
---|
95 | 68 | /* Default size for MTU and freelist buffer sizes */ |
---|
96 | | -#define NFP_NET_DEFAULT_MTU 1500 |
---|
| 69 | +#define NFP_NET_DEFAULT_MTU 1500U |
---|
97 | 70 | |
---|
98 | 71 | /* Maximum number of bytes prepended to a packet */ |
---|
99 | 72 | #define NFP_NET_MAX_PREPEND 64 |
---|
.. | .. |
---|
188 | 161 | __le16 data_len; /* Length of frame + meta data */ |
---|
189 | 162 | } __packed; |
---|
190 | 163 | __le32 vals[4]; |
---|
| 164 | + __le64 vals8[2]; |
---|
191 | 165 | }; |
---|
192 | 166 | }; |
---|
193 | 167 | |
---|
.. | .. |
---|
267 | 241 | #define PCIE_DESC_RX_I_TCP_CSUM_OK cpu_to_le16(BIT(11)) |
---|
268 | 242 | #define PCIE_DESC_RX_I_UDP_CSUM cpu_to_le16(BIT(10)) |
---|
269 | 243 | #define PCIE_DESC_RX_I_UDP_CSUM_OK cpu_to_le16(BIT(9)) |
---|
270 | | -#define PCIE_DESC_RX_BPF cpu_to_le16(BIT(8)) |
---|
| 244 | +#define PCIE_DESC_RX_DECRYPTED cpu_to_le16(BIT(8)) |
---|
271 | 245 | #define PCIE_DESC_RX_EOP cpu_to_le16(BIT(7)) |
---|
272 | 246 | #define PCIE_DESC_RX_IP4_CSUM cpu_to_le16(BIT(6)) |
---|
273 | 247 | #define PCIE_DESC_RX_IP4_CSUM_OK cpu_to_le16(BIT(5)) |
---|
.. | .. |
---|
394 | 368 | * @hw_csum_rx_inner_ok: Counter of packets where the inner HW checksum was OK |
---|
395 | 369 | * @hw_csum_rx_complete: Counter of packets with CHECKSUM_COMPLETE reported |
---|
396 | 370 | * @hw_csum_rx_error: Counter of packets with bad checksums |
---|
| 371 | + * @hw_tls_rx: Number of packets with TLS decrypted by hardware |
---|
397 | 372 | * @tx_sync: Seqlock for atomic updates of TX stats |
---|
398 | 373 | * @tx_pkts: Number of Transmitted packets |
---|
399 | 374 | * @tx_bytes: Number of Transmitted bytes |
---|
.. | .. |
---|
401 | 376 | * @hw_csum_tx_inner: Counter of inner TX checksum offload requests |
---|
402 | 377 | * @tx_gather: Counter of packets with Gather DMA |
---|
403 | 378 | * @tx_lso: Counter of LSO packets sent |
---|
| 379 | + * @hw_tls_tx: Counter of TLS packets sent with crypto offloaded to HW |
---|
| 380 | + * @tls_tx_fallback: Counter of TLS packets sent which had to be encrypted |
---|
| 381 | + * by the fallback path because packets came out of order |
---|
| 382 | + * @tls_tx_no_fallback: Counter of TLS packets not sent because the fallback |
---|
| 383 | + * path could not encrypt them |
---|
404 | 384 | * @tx_errors: How many TX errors were encountered |
---|
405 | 385 | * @tx_busy: How often was TX busy (no space)? |
---|
406 | 386 | * @rx_replace_buf_alloc_fail: Counter of RX buffer allocation failures |
---|
.. | .. |
---|
421 | 401 | struct { |
---|
422 | 402 | struct tasklet_struct tasklet; |
---|
423 | 403 | struct sk_buff_head queue; |
---|
424 | | - struct spinlock lock; |
---|
| 404 | + spinlock_t lock; |
---|
425 | 405 | }; |
---|
426 | 406 | }; |
---|
427 | 407 | |
---|
.. | .. |
---|
437 | 417 | u64 hw_csum_rx_ok; |
---|
438 | 418 | u64 hw_csum_rx_inner_ok; |
---|
439 | 419 | u64 hw_csum_rx_complete; |
---|
| 420 | + u64 hw_tls_rx; |
---|
| 421 | + |
---|
| 422 | + u64 hw_csum_rx_error; |
---|
| 423 | + u64 rx_replace_buf_alloc_fail; |
---|
440 | 424 | |
---|
441 | 425 | struct nfp_net_tx_ring *xdp_ring; |
---|
442 | 426 | |
---|
443 | 427 | struct u64_stats_sync tx_sync; |
---|
444 | 428 | u64 tx_pkts; |
---|
445 | 429 | u64 tx_bytes; |
---|
446 | | - u64 hw_csum_tx; |
---|
| 430 | + |
---|
| 431 | + u64 ____cacheline_aligned_in_smp hw_csum_tx; |
---|
447 | 432 | u64 hw_csum_tx_inner; |
---|
448 | 433 | u64 tx_gather; |
---|
449 | 434 | u64 tx_lso; |
---|
| 435 | + u64 hw_tls_tx; |
---|
450 | 436 | |
---|
451 | | - u64 hw_csum_rx_error; |
---|
452 | | - u64 rx_replace_buf_alloc_fail; |
---|
| 437 | + u64 tls_tx_fallback; |
---|
| 438 | + u64 tls_tx_no_fallback; |
---|
453 | 439 | u64 tx_errors; |
---|
454 | 440 | u64 tx_busy; |
---|
| 441 | + |
---|
| 442 | + /* Cold data follows */ |
---|
455 | 443 | |
---|
456 | 444 | u32 irq_vector; |
---|
457 | 445 | irq_handler_t handler; |
---|
.. | .. |
---|
487 | 475 | * @netdev: Backpointer to net_device structure |
---|
488 | 476 | * @is_vf: Is the driver attached to a VF? |
---|
489 | 477 | * @chained_metadata_format: Firemware will use new metadata format |
---|
| 478 | + * @ktls_tx: Is kTLS TX enabled? |
---|
490 | 479 | * @rx_dma_dir: Mapping direction for RX buffers |
---|
491 | 480 | * @rx_dma_off: Offset at which DMA packets (for XDP headroom) |
---|
492 | 481 | * @rx_offset: Offset in the RX buffers where packet data starts |
---|
.. | .. |
---|
511 | 500 | |
---|
512 | 501 | u8 is_vf:1; |
---|
513 | 502 | u8 chained_metadata_format:1; |
---|
| 503 | + u8 ktls_tx:1; |
---|
514 | 504 | |
---|
515 | 505 | u8 rx_dma_dir; |
---|
516 | 506 | u8 rx_offset; |
---|
.. | .. |
---|
567 | 557 | * @exn_name: Name for Exception interrupt |
---|
568 | 558 | * @shared_handler: Handler for shared interrupts |
---|
569 | 559 | * @shared_name: Name for shared interrupt |
---|
570 | | - * @me_freq_mhz: ME clock_freq (MHz) |
---|
571 | | - * @reconfig_lock: Protects HW reconfiguration request regs/machinery |
---|
| 560 | + * @reconfig_lock: Protects @reconfig_posted, @reconfig_timer_active, |
---|
| 561 | + * @reconfig_sync_present and HW reconfiguration request |
---|
| 562 | + * regs/machinery from async requests (sync must take |
---|
| 563 | + * @bar_lock) |
---|
572 | 564 | * @reconfig_posted: Pending reconfig bits coming from async sources |
---|
573 | 565 | * @reconfig_timer_active: Timer for reading reconfiguration results is pending |
---|
574 | 566 | * @reconfig_sync_present: Some thread is performing synchronous reconfig |
---|
575 | 567 | * @reconfig_timer: Timer for async reading of reconfig results |
---|
| 568 | + * @reconfig_in_progress_update: Update FW is processing now (debug only) |
---|
| 569 | + * @bar_lock: vNIC config BAR access lock, protects: update, |
---|
| 570 | + * mailbox area, crypto TLV |
---|
576 | 571 | * @link_up: Is the link up? |
---|
577 | 572 | * @link_status_lock: Protects @link_* and ensures atomicity with BAR reading |
---|
578 | 573 | * @rx_coalesce_usecs: RX interrupt moderation usecs delay parameter |
---|
579 | 574 | * @rx_coalesce_max_frames: RX interrupt moderation frame count parameter |
---|
580 | 575 | * @tx_coalesce_usecs: TX interrupt moderation usecs delay parameter |
---|
581 | 576 | * @tx_coalesce_max_frames: TX interrupt moderation frame count parameter |
---|
582 | | - * @vxlan_ports: VXLAN ports for RX inner csum offload communicated to HW |
---|
583 | | - * @vxlan_usecnt: IPv4/IPv6 VXLAN port use counts |
---|
584 | 577 | * @qcp_cfg: Pointer to QCP queue used for configuration notification |
---|
585 | 578 | * @tx_bar: Pointer to mapped TX queues |
---|
586 | 579 | * @rx_bar: Pointer to mapped FL/RX queues |
---|
587 | 580 | * @tlv_caps: Parsed TLV capabilities |
---|
| 581 | + * @ktls_tx_conn_cnt: Number of offloaded kTLS TX connections |
---|
| 582 | + * @ktls_rx_conn_cnt: Number of offloaded kTLS RX connections |
---|
| 583 | + * @ktls_conn_id_gen: Trivial generator for kTLS connection ids (for TX) |
---|
| 584 | + * @ktls_no_space: Counter of firmware rejecting kTLS connection due to |
---|
| 585 | + * lack of space |
---|
| 586 | + * @ktls_rx_resync_req: Counter of TLS RX resync requested |
---|
| 587 | + * @ktls_rx_resync_ign: Counter of TLS RX resync requests ignored |
---|
| 588 | + * @ktls_rx_resync_sent: Counter of TLS RX resync completed |
---|
| 589 | + * @mbox_cmsg: Common Control Message via vNIC mailbox state |
---|
| 590 | + * @mbox_cmsg.queue: CCM mbox queue of pending messages |
---|
| 591 | + * @mbox_cmsg.wq: CCM mbox wait queue of waiting processes |
---|
| 592 | + * @mbox_cmsg.workq: CCM mbox work queue for @wait_work and @runq_work |
---|
| 593 | + * @mbox_cmsg.wait_work: CCM mbox posted msg reconfig wait work |
---|
| 594 | + * @mbox_cmsg.runq_work: CCM mbox posted msg queue runner work |
---|
| 595 | + * @mbox_cmsg.tag: CCM mbox message tag allocator |
---|
588 | 596 | * @debugfs_dir: Device directory in debugfs |
---|
589 | 597 | * @vnic_list: Entry on device vNIC list |
---|
590 | 598 | * @pdev: Backpointer to PCI device |
---|
.. | .. |
---|
631 | 639 | irq_handler_t shared_handler; |
---|
632 | 640 | char shared_name[IFNAMSIZ + 8]; |
---|
633 | 641 | |
---|
634 | | - u32 me_freq_mhz; |
---|
635 | | - |
---|
636 | 642 | bool link_up; |
---|
637 | 643 | spinlock_t link_status_lock; |
---|
638 | 644 | |
---|
.. | .. |
---|
641 | 647 | bool reconfig_timer_active; |
---|
642 | 648 | bool reconfig_sync_present; |
---|
643 | 649 | struct timer_list reconfig_timer; |
---|
| 650 | + u32 reconfig_in_progress_update; |
---|
| 651 | + |
---|
| 652 | + struct semaphore bar_lock; |
---|
644 | 653 | |
---|
645 | 654 | u32 rx_coalesce_usecs; |
---|
646 | 655 | u32 rx_coalesce_max_frames; |
---|
647 | 656 | u32 tx_coalesce_usecs; |
---|
648 | 657 | u32 tx_coalesce_max_frames; |
---|
649 | | - |
---|
650 | | - __be16 vxlan_ports[NFP_NET_N_VXLAN_PORTS]; |
---|
651 | | - u8 vxlan_usecnt[NFP_NET_N_VXLAN_PORTS]; |
---|
652 | 658 | |
---|
653 | 659 | u8 __iomem *qcp_cfg; |
---|
654 | 660 | |
---|
.. | .. |
---|
656 | 662 | u8 __iomem *rx_bar; |
---|
657 | 663 | |
---|
658 | 664 | struct nfp_net_tlv_caps tlv_caps; |
---|
| 665 | + |
---|
| 666 | + unsigned int ktls_tx_conn_cnt; |
---|
| 667 | + unsigned int ktls_rx_conn_cnt; |
---|
| 668 | + |
---|
| 669 | + atomic64_t ktls_conn_id_gen; |
---|
| 670 | + |
---|
| 671 | + atomic_t ktls_no_space; |
---|
| 672 | + atomic_t ktls_rx_resync_req; |
---|
| 673 | + atomic_t ktls_rx_resync_ign; |
---|
| 674 | + atomic_t ktls_rx_resync_sent; |
---|
| 675 | + |
---|
| 676 | + struct { |
---|
| 677 | + struct sk_buff_head queue; |
---|
| 678 | + wait_queue_head_t wq; |
---|
| 679 | + struct workqueue_struct *workq; |
---|
| 680 | + struct work_struct wait_work; |
---|
| 681 | + struct work_struct runq_work; |
---|
| 682 | + u16 tag; |
---|
| 683 | + } mbox_cmsg; |
---|
659 | 684 | |
---|
660 | 685 | struct dentry *debugfs_dir; |
---|
661 | 686 | |
---|
.. | .. |
---|
866 | 891 | spin_unlock_bh(&nn->r_vecs[0].lock); |
---|
867 | 892 | } |
---|
868 | 893 | |
---|
| 894 | +static inline void nn_ctrl_bar_lock(struct nfp_net *nn) |
---|
| 895 | +{ |
---|
| 896 | + down(&nn->bar_lock); |
---|
| 897 | +} |
---|
| 898 | + |
---|
| 899 | +static inline bool nn_ctrl_bar_trylock(struct nfp_net *nn) |
---|
| 900 | +{ |
---|
| 901 | + return !down_trylock(&nn->bar_lock); |
---|
| 902 | +} |
---|
| 903 | + |
---|
| 904 | +static inline void nn_ctrl_bar_unlock(struct nfp_net *nn) |
---|
| 905 | +{ |
---|
| 906 | + up(&nn->bar_lock); |
---|
| 907 | +} |
---|
| 908 | + |
---|
869 | 909 | /* Globals */ |
---|
870 | 910 | extern const char nfp_driver_version[]; |
---|
871 | 911 | |
---|
.. | .. |
---|
881 | 921 | void __iomem *ctrl_bar); |
---|
882 | 922 | |
---|
883 | 923 | struct nfp_net * |
---|
884 | | -nfp_net_alloc(struct pci_dev *pdev, bool needs_netdev, |
---|
| 924 | +nfp_net_alloc(struct pci_dev *pdev, void __iomem *ctrl_bar, bool needs_netdev, |
---|
885 | 925 | unsigned int max_tx_rings, unsigned int max_rx_rings); |
---|
886 | 926 | void nfp_net_free(struct nfp_net *nn); |
---|
887 | 927 | |
---|
.. | .. |
---|
893 | 933 | |
---|
894 | 934 | void nfp_net_set_ethtool_ops(struct net_device *netdev); |
---|
895 | 935 | void nfp_net_info(struct nfp_net *nn); |
---|
| 936 | +int __nfp_net_reconfig(struct nfp_net *nn, u32 update); |
---|
896 | 937 | int nfp_net_reconfig(struct nfp_net *nn, u32 update); |
---|
897 | 938 | unsigned int nfp_net_rss_key_sz(struct nfp_net *nn); |
---|
898 | 939 | void nfp_net_rss_write_itbl(struct nfp_net *nn); |
---|
899 | 940 | void nfp_net_rss_write_key(struct nfp_net *nn); |
---|
900 | 941 | void nfp_net_coalesce_write_cfg(struct nfp_net *nn); |
---|
| 942 | +int nfp_net_mbox_lock(struct nfp_net *nn, unsigned int data_size); |
---|
| 943 | +int nfp_net_mbox_reconfig(struct nfp_net *nn, u32 mbox_cmd); |
---|
| 944 | +int nfp_net_mbox_reconfig_and_unlock(struct nfp_net *nn, u32 mbox_cmd); |
---|
| 945 | +void nfp_net_mbox_reconfig_post(struct nfp_net *nn, u32 update); |
---|
| 946 | +int nfp_net_mbox_reconfig_wait_posted(struct nfp_net *nn); |
---|
901 | 947 | |
---|
902 | 948 | unsigned int |
---|
903 | 949 | nfp_net_irqs_alloc(struct pci_dev *pdev, struct msix_entry *irq_entries, |
---|