1ae06c70bSJeff Kirsher /* SPDX-License-Identifier: GPL-2.0 */
2*4c44b450SPiotr Kwapulinski /* Copyright(c) 1999 - 2024 Intel Corporation. */
33047f90bSGreg Rose
43047f90bSGreg Rose #ifndef __IXGBE_VF_H__
53047f90bSGreg Rose #define __IXGBE_VF_H__
63047f90bSGreg Rose
73047f90bSGreg Rose #include <linux/pci.h>
83047f90bSGreg Rose #include <linux/delay.h>
93047f90bSGreg Rose #include <linux/interrupt.h>
103047f90bSGreg Rose #include <linux/if_ether.h>
115c58c47aSJiri Pirko #include <linux/netdevice.h>
123047f90bSGreg Rose
133047f90bSGreg Rose #include "defines.h"
143047f90bSGreg Rose #include "regs.h"
153047f90bSGreg Rose #include "mbx.h"
163047f90bSGreg Rose
173047f90bSGreg Rose struct ixgbe_hw;
183047f90bSGreg Rose
193047f90bSGreg Rose struct ixgbe_mac_operations {
203047f90bSGreg Rose s32 (*init_hw)(struct ixgbe_hw *);
213047f90bSGreg Rose s32 (*reset_hw)(struct ixgbe_hw *);
223047f90bSGreg Rose s32 (*start_hw)(struct ixgbe_hw *);
233047f90bSGreg Rose s32 (*clear_hw_cntrs)(struct ixgbe_hw *);
243047f90bSGreg Rose enum ixgbe_media_type (*get_media_type)(struct ixgbe_hw *);
253047f90bSGreg Rose s32 (*get_mac_addr)(struct ixgbe_hw *, u8 *);
263047f90bSGreg Rose s32 (*stop_adapter)(struct ixgbe_hw *);
273047f90bSGreg Rose s32 (*get_bus_info)(struct ixgbe_hw *);
287921f4dcSAlexander Duyck s32 (*negotiate_api_version)(struct ixgbe_hw *hw, int api);
293047f90bSGreg Rose
303047f90bSGreg Rose /* Link */
313047f90bSGreg Rose s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool);
323047f90bSGreg Rose s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool);
333047f90bSGreg Rose s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *,
343047f90bSGreg Rose bool *);
353047f90bSGreg Rose
363047f90bSGreg Rose /* RAR, Multicast, VLAN */
373047f90bSGreg Rose s32 (*set_rar)(struct ixgbe_hw *, u32, u8 *, u32);
3846ec20ffSGreg Rose s32 (*set_uc_addr)(struct ixgbe_hw *, u32, u8 *);
393047f90bSGreg Rose s32 (*init_rx_addrs)(struct ixgbe_hw *);
405c58c47aSJiri Pirko s32 (*update_mc_addr_list)(struct ixgbe_hw *, struct net_device *);
418b44a8a0STony Nguyen s32 (*update_xcast_mode)(struct ixgbe_hw *, int);
42443ebdd6SSlawomir Mrozowicz s32 (*get_link_state)(struct ixgbe_hw *hw, bool *link_state);
433047f90bSGreg Rose s32 (*enable_mc)(struct ixgbe_hw *);
443047f90bSGreg Rose s32 (*disable_mc)(struct ixgbe_hw *);
453047f90bSGreg Rose s32 (*clear_vfta)(struct ixgbe_hw *);
463047f90bSGreg Rose s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool);
476a11e52bSTony Nguyen s32 (*set_rlpml)(struct ixgbe_hw *, u16);
483047f90bSGreg Rose };
493047f90bSGreg Rose
503047f90bSGreg Rose enum ixgbe_mac_type {
513047f90bSGreg Rose ixgbe_mac_unknown = 0,
523047f90bSGreg Rose ixgbe_mac_82599_vf,
532316aa2aSGreg Rose ixgbe_mac_X540_vf,
5447068b0dSEmil Tantilov ixgbe_mac_X550_vf,
5547068b0dSEmil Tantilov ixgbe_mac_X550EM_x_vf,
561d94f987SDon Skidmore ixgbe_mac_x550em_a_vf,
57*4c44b450SPiotr Kwapulinski ixgbe_mac_e610,
58*4c44b450SPiotr Kwapulinski ixgbe_mac_e610_vf,
593047f90bSGreg Rose ixgbe_num_macs
603047f90bSGreg Rose };
613047f90bSGreg Rose
623047f90bSGreg Rose struct ixgbe_mac_info {
633047f90bSGreg Rose struct ixgbe_mac_operations ops;
643047f90bSGreg Rose u8 addr[6];
653047f90bSGreg Rose u8 perm_addr[6];
663047f90bSGreg Rose
673047f90bSGreg Rose enum ixgbe_mac_type type;
683047f90bSGreg Rose
693047f90bSGreg Rose s32 mc_filter_type;
703047f90bSGreg Rose
713047f90bSGreg Rose bool get_link_status;
723047f90bSGreg Rose u32 max_tx_queues;
733047f90bSGreg Rose u32 max_rx_queues;
743047f90bSGreg Rose u32 max_msix_vectors;
753047f90bSGreg Rose };
763047f90bSGreg Rose
773047f90bSGreg Rose struct ixgbe_mbx_operations {
783047f90bSGreg Rose s32 (*init_params)(struct ixgbe_hw *hw);
79c8692598SRadoslaw Tyl void (*release)(struct ixgbe_hw *hw);
803047f90bSGreg Rose s32 (*read)(struct ixgbe_hw *, u32 *, u16);
813047f90bSGreg Rose s32 (*write)(struct ixgbe_hw *, u32 *, u16);
823047f90bSGreg Rose s32 (*check_for_msg)(struct ixgbe_hw *);
833047f90bSGreg Rose s32 (*check_for_ack)(struct ixgbe_hw *);
843047f90bSGreg Rose s32 (*check_for_rst)(struct ixgbe_hw *);
853047f90bSGreg Rose };
863047f90bSGreg Rose
873047f90bSGreg Rose struct ixgbe_mbx_stats {
883047f90bSGreg Rose u32 msgs_tx;
893047f90bSGreg Rose u32 msgs_rx;
903047f90bSGreg Rose
913047f90bSGreg Rose u32 acks;
923047f90bSGreg Rose u32 reqs;
933047f90bSGreg Rose u32 rsts;
943047f90bSGreg Rose };
953047f90bSGreg Rose
963047f90bSGreg Rose struct ixgbe_mbx_info {
973047f90bSGreg Rose struct ixgbe_mbx_operations ops;
983047f90bSGreg Rose struct ixgbe_mbx_stats stats;
993047f90bSGreg Rose u32 timeout;
1003047f90bSGreg Rose u32 udelay;
101c8692598SRadoslaw Tyl u32 vf_mailbox;
1023047f90bSGreg Rose u16 size;
1033047f90bSGreg Rose };
1043047f90bSGreg Rose
1053047f90bSGreg Rose struct ixgbe_hw {
1063047f90bSGreg Rose void *back;
1073047f90bSGreg Rose
1083047f90bSGreg Rose u8 __iomem *hw_addr;
1093047f90bSGreg Rose
1103047f90bSGreg Rose struct ixgbe_mac_info mac;
1113047f90bSGreg Rose struct ixgbe_mbx_info mbx;
1123047f90bSGreg Rose
1133047f90bSGreg Rose u16 device_id;
1143047f90bSGreg Rose u16 subsystem_vendor_id;
1153047f90bSGreg Rose u16 subsystem_device_id;
1163047f90bSGreg Rose u16 vendor_id;
1173047f90bSGreg Rose
1183047f90bSGreg Rose u8 revision_id;
1193047f90bSGreg Rose bool adapter_stopped;
12031186785SAlexander Duyck
12131186785SAlexander Duyck int api_version;
1223047f90bSGreg Rose };
1233047f90bSGreg Rose
1243047f90bSGreg Rose struct ixgbevf_hw_stats {
1253047f90bSGreg Rose u64 base_vfgprc;
1263047f90bSGreg Rose u64 base_vfgptc;
1273047f90bSGreg Rose u64 base_vfgorc;
1283047f90bSGreg Rose u64 base_vfgotc;
1293047f90bSGreg Rose u64 base_vfmprc;
1303047f90bSGreg Rose
1313047f90bSGreg Rose u64 last_vfgprc;
1323047f90bSGreg Rose u64 last_vfgptc;
1333047f90bSGreg Rose u64 last_vfgorc;
1343047f90bSGreg Rose u64 last_vfgotc;
1353047f90bSGreg Rose u64 last_vfmprc;
1363047f90bSGreg Rose
1373047f90bSGreg Rose u64 vfgprc;
1383047f90bSGreg Rose u64 vfgptc;
1393047f90bSGreg Rose u64 vfgorc;
1403047f90bSGreg Rose u64 vfgotc;
1413047f90bSGreg Rose u64 vfmprc;
14233bd9f60SGreg Rose
14333bd9f60SGreg Rose u64 saved_reset_vfgprc;
14433bd9f60SGreg Rose u64 saved_reset_vfgptc;
14533bd9f60SGreg Rose u64 saved_reset_vfgorc;
14633bd9f60SGreg Rose u64 saved_reset_vfgotc;
14733bd9f60SGreg Rose u64 saved_reset_vfmprc;
1483047f90bSGreg Rose };
1493047f90bSGreg Rose
1503047f90bSGreg Rose struct ixgbevf_info {
1513047f90bSGreg Rose enum ixgbe_mac_type mac;
1523d8fe98fSStephen Hemminger const struct ixgbe_mac_operations *mac_ops;
1533047f90bSGreg Rose };
1543047f90bSGreg Rose
155dbf8b0d8SMark Rustad #define IXGBE_FAILED_READ_REG 0xffffffffU
156dbf8b0d8SMark Rustad
157dbf8b0d8SMark Rustad #define IXGBE_REMOVED(a) unlikely(!(a))
158dbf8b0d8SMark Rustad
ixgbe_write_reg(struct ixgbe_hw * hw,u32 reg,u32 value)15906380db6SMark Rustad static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value)
16006380db6SMark Rustad {
1616aa7de05SMark Rutland u8 __iomem *reg_addr = READ_ONCE(hw->hw_addr);
162984b0ee3SMark Rustad
163984b0ee3SMark Rustad if (IXGBE_REMOVED(reg_addr))
164984b0ee3SMark Rustad return;
165984b0ee3SMark Rustad writel(value, reg_addr + reg);
16606380db6SMark Rustad }
167dec0d8e4SJeff Kirsher
16806380db6SMark Rustad #define IXGBE_WRITE_REG(h, r, v) ixgbe_write_reg(h, r, v)
16906380db6SMark Rustad
17032c74949SMark Rustad u32 ixgbevf_read_reg(struct ixgbe_hw *hw, u32 reg);
17132c74949SMark Rustad #define IXGBE_READ_REG(h, r) ixgbevf_read_reg(h, r)
17206380db6SMark Rustad
ixgbe_write_reg_array(struct ixgbe_hw * hw,u32 reg,u32 offset,u32 value)17306380db6SMark Rustad static inline void ixgbe_write_reg_array(struct ixgbe_hw *hw, u32 reg,
17406380db6SMark Rustad u32 offset, u32 value)
17506380db6SMark Rustad {
17606380db6SMark Rustad ixgbe_write_reg(hw, reg + (offset << 2), value);
17706380db6SMark Rustad }
178dec0d8e4SJeff Kirsher
17906380db6SMark Rustad #define IXGBE_WRITE_REG_ARRAY(h, r, o, v) ixgbe_write_reg_array(h, r, o, v)
18006380db6SMark Rustad
ixgbe_read_reg_array(struct ixgbe_hw * hw,u32 reg,u32 offset)18106380db6SMark Rustad static inline u32 ixgbe_read_reg_array(struct ixgbe_hw *hw, u32 reg,
18206380db6SMark Rustad u32 offset)
18306380db6SMark Rustad {
18432c74949SMark Rustad return ixgbevf_read_reg(hw, reg + (offset << 2));
18506380db6SMark Rustad }
186dec0d8e4SJeff Kirsher
18706380db6SMark Rustad #define IXGBE_READ_REG_ARRAY(h, r, o) ixgbe_read_reg_array(h, r, o)
18806380db6SMark Rustad
18956e94095SAlexander Duyck int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,
19056e94095SAlexander Duyck unsigned int *default_tc);
19194cf66f8SVlad Zolotarov int ixgbevf_get_reta_locked(struct ixgbe_hw *hw, u32 *reta, int num_rx_queues);
192ad1431e2SVlad Zolotarov int ixgbevf_get_rss_key_locked(struct ixgbe_hw *hw, u8 *rss_key);
1933047f90bSGreg Rose #endif /* __IXGBE_VF_H__ */
194