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/phylink.h> 8 #include <linux/types.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 u8 aui; 46 u8 fec; 47 48 /* Cached top bits of the HW time counter for 40b -> 64b conversion */ 49 u32 time_high; 50 /* Protect readers of @time_offset, writers take @time_lock. */ 51 struct u64_stats_sync time_seq; 52 /* Offset in ns between free running NIC PHC and time set via PTP 53 * clock callbacks 54 */ 55 s64 time_offset; 56 57 u16 num_tx_queues; 58 u16 num_rx_queues; 59 60 u8 indir_tbl[FBNIC_RPC_RSS_TBL_COUNT][FBNIC_RPC_RSS_TBL_SIZE]; 61 u32 rss_key[FBNIC_RPC_RSS_KEY_DWORD_LEN]; 62 u32 rss_flow_hash[FBNIC_NUM_HASH_OPT]; 63 64 /* Storage for stats after ring destruction */ 65 struct fbnic_queue_stats tx_stats; 66 struct fbnic_queue_stats rx_stats; 67 u64 link_down_events; 68 69 /* Time stamping filter config */ 70 struct kernel_hwtstamp_config hwtstamp_config; 71 }; 72 73 int __fbnic_open(struct fbnic_net *fbn); 74 void fbnic_up(struct fbnic_net *fbn); 75 void fbnic_down(struct fbnic_net *fbn); 76 void fbnic_down_noidle(struct fbnic_net *fbn); 77 78 struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd); 79 void fbnic_netdev_free(struct fbnic_dev *fbd); 80 int fbnic_netdev_register(struct net_device *netdev); 81 void fbnic_netdev_unregister(struct net_device *netdev); 82 void fbnic_reset_queues(struct fbnic_net *fbn, 83 unsigned int tx, unsigned int rx); 84 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 void fbnic_phylink_get_pauseparam(struct net_device *netdev, 97 struct ethtool_pauseparam *pause); 98 int fbnic_phylink_set_pauseparam(struct net_device *netdev, 99 struct ethtool_pauseparam *pause); 100 int fbnic_phylink_ethtool_ksettings_get(struct net_device *netdev, 101 struct ethtool_link_ksettings *cmd); 102 int fbnic_phylink_get_fecparam(struct net_device *netdev, 103 struct ethtool_fecparam *fecparam); 104 int fbnic_phylink_init(struct net_device *netdev); 105 #endif /* _FBNIC_NETDEV_H_ */ 106