xref: /linux/drivers/net/ethernet/meta/fbnic/fbnic_netdev.h (revision 55d0969c451159cff86949b38c39171cab962069)
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 struct fbnic_net {
15 	struct fbnic_ring *tx[FBNIC_MAX_TXQS];
16 	struct fbnic_ring *rx[FBNIC_MAX_RXQS];
17 
18 	struct net_device *netdev;
19 	struct fbnic_dev *fbd;
20 
21 	u32 txq_size;
22 	u32 hpq_size;
23 	u32 ppq_size;
24 	u32 rcq_size;
25 
26 	u16 num_napi;
27 
28 	struct phylink *phylink;
29 	struct phylink_config phylink_config;
30 	struct phylink_pcs phylink_pcs;
31 
32 	/* TBD: Remove these when phylink supports FEC and lane config */
33 	u8 fec;
34 	u8 link_mode;
35 
36 	u16 num_tx_queues;
37 	u16 num_rx_queues;
38 
39 	u8 indir_tbl[FBNIC_RPC_RSS_TBL_COUNT][FBNIC_RPC_RSS_TBL_SIZE];
40 	u32 rss_key[FBNIC_RPC_RSS_KEY_DWORD_LEN];
41 	u32 rss_flow_hash[FBNIC_NUM_HASH_OPT];
42 
43 	/* Storage for stats after ring destruction */
44 	struct fbnic_queue_stats tx_stats;
45 	struct fbnic_queue_stats rx_stats;
46 	u64 link_down_events;
47 
48 	struct list_head napis;
49 };
50 
51 int __fbnic_open(struct fbnic_net *fbn);
52 void fbnic_up(struct fbnic_net *fbn);
53 void fbnic_down(struct fbnic_net *fbn);
54 
55 struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd);
56 void fbnic_netdev_free(struct fbnic_dev *fbd);
57 int fbnic_netdev_register(struct net_device *netdev);
58 void fbnic_netdev_unregister(struct net_device *netdev);
59 void fbnic_reset_queues(struct fbnic_net *fbn,
60 			unsigned int tx, unsigned int rx);
61 void fbnic_set_ethtool_ops(struct net_device *dev);
62 
63 void __fbnic_set_rx_mode(struct net_device *netdev);
64 void fbnic_clear_rx_mode(struct net_device *netdev);
65 
66 int fbnic_phylink_init(struct net_device *netdev);
67 #endif /* _FBNIC_NETDEV_H_ */
68