1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (c) Meta Platforms, Inc. and affiliates. */ 3 4 #ifndef _FBNIC_NETDEV_H_ 5 #define _FBNIC_NETDEV_H_ 6 7 #include <linux/types.h> 8 #include <linux/phylink.h> 9 10 #include "fbnic_csr.h" 11 #include "fbnic_rpc.h" 12 #include "fbnic_txrx.h" 13 14 #define FBNIC_MAX_NAPI_VECTORS 128u 15 #define FBNIC_MIN_RXD_PER_FRAME 2 16 17 /* Natively supported tunnel GSO features (not thru GSO_PARTIAL) */ 18 #define FBNIC_TUN_GSO_FEATURES NETIF_F_GSO_IPXIP6 19 20 struct fbnic_net { 21 struct fbnic_ring *tx[FBNIC_MAX_TXQS]; 22 struct fbnic_ring *rx[FBNIC_MAX_RXQS]; 23 24 struct fbnic_napi_vector *napi[FBNIC_MAX_NAPI_VECTORS]; 25 26 struct net_device *netdev; 27 struct fbnic_dev *fbd; 28 29 u32 txq_size; 30 u32 hpq_size; 31 u32 ppq_size; 32 u32 rcq_size; 33 34 u16 rx_usecs; 35 u16 tx_usecs; 36 37 u32 rx_max_frames; 38 39 u16 num_napi; 40 41 struct phylink *phylink; 42 struct phylink_config phylink_config; 43 struct phylink_pcs phylink_pcs; 44 45 /* TBD: Remove these when phylink supports FEC and lane config */ 46 u8 fec; 47 u8 link_mode; 48 49 /* Cached top bits of the HW time counter for 40b -> 64b conversion */ 50 u32 time_high; 51 /* Protect readers of @time_offset, writers take @time_lock. */ 52 struct u64_stats_sync time_seq; 53 /* Offset in ns between free running NIC PHC and time set via PTP 54 * clock callbacks 55 */ 56 s64 time_offset; 57 58 u16 num_tx_queues; 59 u16 num_rx_queues; 60 61 u8 indir_tbl[FBNIC_RPC_RSS_TBL_COUNT][FBNIC_RPC_RSS_TBL_SIZE]; 62 u32 rss_key[FBNIC_RPC_RSS_KEY_DWORD_LEN]; 63 u32 rss_flow_hash[FBNIC_NUM_HASH_OPT]; 64 65 /* Storage for stats after ring destruction */ 66 struct fbnic_queue_stats tx_stats; 67 struct fbnic_queue_stats rx_stats; 68 u64 link_down_events; 69 70 /* Time stampinn filter config */ 71 struct kernel_hwtstamp_config hwtstamp_config; 72 }; 73 74 int __fbnic_open(struct fbnic_net *fbn); 75 void fbnic_up(struct fbnic_net *fbn); 76 void fbnic_down(struct fbnic_net *fbn); 77 void fbnic_down_noidle(struct fbnic_net *fbn); 78 79 struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd); 80 void fbnic_netdev_free(struct fbnic_dev *fbd); 81 int fbnic_netdev_register(struct net_device *netdev); 82 void fbnic_netdev_unregister(struct net_device *netdev); 83 void fbnic_reset_queues(struct fbnic_net *fbn, 84 unsigned int tx, unsigned int rx); 85 void fbnic_set_ethtool_ops(struct net_device *dev); 86 87 int fbnic_ptp_setup(struct fbnic_dev *fbd); 88 void fbnic_ptp_destroy(struct fbnic_dev *fbd); 89 void fbnic_time_init(struct fbnic_net *fbn); 90 int fbnic_time_start(struct fbnic_net *fbn); 91 void fbnic_time_stop(struct fbnic_net *fbn); 92 93 void __fbnic_set_rx_mode(struct net_device *netdev); 94 void fbnic_clear_rx_mode(struct net_device *netdev); 95 96 int fbnic_phylink_init(struct net_device *netdev); 97 #endif /* _FBNIC_NETDEV_H_ */ 98