2018-03-23 01:08:48 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2018-04-26 23:08:09 +08:00
|
|
|
/* Copyright(c) 1999 - 2018 Intel Corporation. */
|
2010-01-09 10:23:31 +08:00
|
|
|
|
|
|
|
#ifndef __IXGBE_VF_H__
|
|
|
|
#define __IXGBE_VF_H__
|
|
|
|
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/if_ether.h>
|
2010-03-24 06:58:20 +08:00
|
|
|
#include <linux/netdevice.h>
|
2010-01-09 10:23:31 +08:00
|
|
|
|
|
|
|
#include "defines.h"
|
|
|
|
#include "regs.h"
|
|
|
|
#include "mbx.h"
|
|
|
|
|
|
|
|
struct ixgbe_hw;
|
|
|
|
|
|
|
|
struct ixgbe_mac_operations {
|
|
|
|
s32 (*init_hw)(struct ixgbe_hw *);
|
|
|
|
s32 (*reset_hw)(struct ixgbe_hw *);
|
|
|
|
s32 (*start_hw)(struct ixgbe_hw *);
|
|
|
|
s32 (*clear_hw_cntrs)(struct ixgbe_hw *);
|
|
|
|
enum ixgbe_media_type (*get_media_type)(struct ixgbe_hw *);
|
|
|
|
s32 (*get_mac_addr)(struct ixgbe_hw *, u8 *);
|
|
|
|
s32 (*stop_adapter)(struct ixgbe_hw *);
|
|
|
|
s32 (*get_bus_info)(struct ixgbe_hw *);
|
2016-04-15 08:37:15 +08:00
|
|
|
s32 (*negotiate_api_version)(struct ixgbe_hw *hw, int api);
|
2010-01-09 10:23:31 +08:00
|
|
|
|
|
|
|
/* Link */
|
|
|
|
s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool);
|
|
|
|
s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool);
|
|
|
|
s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *,
|
|
|
|
bool *);
|
|
|
|
|
|
|
|
/* RAR, Multicast, VLAN */
|
|
|
|
s32 (*set_rar)(struct ixgbe_hw *, u32, u8 *, u32);
|
2011-05-13 09:33:42 +08:00
|
|
|
s32 (*set_uc_addr)(struct ixgbe_hw *, u32, u8 *);
|
2010-01-09 10:23:31 +08:00
|
|
|
s32 (*init_rx_addrs)(struct ixgbe_hw *);
|
2010-03-24 06:58:20 +08:00
|
|
|
s32 (*update_mc_addr_list)(struct ixgbe_hw *, struct net_device *);
|
2016-04-28 05:14:14 +08:00
|
|
|
s32 (*update_xcast_mode)(struct ixgbe_hw *, int);
|
2010-01-09 10:23:31 +08:00
|
|
|
s32 (*enable_mc)(struct ixgbe_hw *);
|
|
|
|
s32 (*disable_mc)(struct ixgbe_hw *);
|
|
|
|
s32 (*clear_vfta)(struct ixgbe_hw *);
|
|
|
|
s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool);
|
2016-07-14 01:33:16 +08:00
|
|
|
s32 (*set_rlpml)(struct ixgbe_hw *, u16);
|
2010-01-09 10:23:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ixgbe_mac_type {
|
|
|
|
ixgbe_mac_unknown = 0,
|
|
|
|
ixgbe_mac_82599_vf,
|
2010-12-02 15:12:26 +08:00
|
|
|
ixgbe_mac_X540_vf,
|
2014-11-22 15:59:56 +08:00
|
|
|
ixgbe_mac_X550_vf,
|
|
|
|
ixgbe_mac_X550EM_x_vf,
|
2016-06-30 07:32:24 +08:00
|
|
|
ixgbe_mac_x550em_a_vf,
|
2010-01-09 10:23:31 +08:00
|
|
|
ixgbe_num_macs
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ixgbe_mac_info {
|
|
|
|
struct ixgbe_mac_operations ops;
|
|
|
|
u8 addr[6];
|
|
|
|
u8 perm_addr[6];
|
|
|
|
|
|
|
|
enum ixgbe_mac_type type;
|
|
|
|
|
|
|
|
s32 mc_filter_type;
|
|
|
|
|
|
|
|
bool get_link_status;
|
|
|
|
u32 max_tx_queues;
|
|
|
|
u32 max_rx_queues;
|
|
|
|
u32 max_msix_vectors;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ixgbe_mbx_operations {
|
|
|
|
s32 (*init_params)(struct ixgbe_hw *hw);
|
|
|
|
s32 (*read)(struct ixgbe_hw *, u32 *, u16);
|
|
|
|
s32 (*write)(struct ixgbe_hw *, u32 *, u16);
|
|
|
|
s32 (*read_posted)(struct ixgbe_hw *, u32 *, u16);
|
|
|
|
s32 (*write_posted)(struct ixgbe_hw *, u32 *, u16);
|
|
|
|
s32 (*check_for_msg)(struct ixgbe_hw *);
|
|
|
|
s32 (*check_for_ack)(struct ixgbe_hw *);
|
|
|
|
s32 (*check_for_rst)(struct ixgbe_hw *);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ixgbe_mbx_stats {
|
|
|
|
u32 msgs_tx;
|
|
|
|
u32 msgs_rx;
|
|
|
|
|
|
|
|
u32 acks;
|
|
|
|
u32 reqs;
|
|
|
|
u32 rsts;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ixgbe_mbx_info {
|
|
|
|
struct ixgbe_mbx_operations ops;
|
|
|
|
struct ixgbe_mbx_stats stats;
|
|
|
|
u32 timeout;
|
|
|
|
u32 udelay;
|
|
|
|
u32 v2p_mailbox;
|
|
|
|
u16 size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ixgbe_hw {
|
|
|
|
void *back;
|
|
|
|
|
|
|
|
u8 __iomem *hw_addr;
|
|
|
|
|
|
|
|
struct ixgbe_mac_info mac;
|
|
|
|
struct ixgbe_mbx_info mbx;
|
|
|
|
|
|
|
|
u16 device_id;
|
|
|
|
u16 subsystem_vendor_id;
|
|
|
|
u16 subsystem_device_id;
|
|
|
|
u16 vendor_id;
|
|
|
|
|
|
|
|
u8 revision_id;
|
|
|
|
bool adapter_stopped;
|
2012-07-20 16:09:58 +08:00
|
|
|
|
|
|
|
int api_version;
|
2010-01-09 10:23:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ixgbevf_hw_stats {
|
|
|
|
u64 base_vfgprc;
|
|
|
|
u64 base_vfgptc;
|
|
|
|
u64 base_vfgorc;
|
|
|
|
u64 base_vfgotc;
|
|
|
|
u64 base_vfmprc;
|
|
|
|
|
|
|
|
u64 last_vfgprc;
|
|
|
|
u64 last_vfgptc;
|
|
|
|
u64 last_vfgorc;
|
|
|
|
u64 last_vfgotc;
|
|
|
|
u64 last_vfmprc;
|
|
|
|
|
|
|
|
u64 vfgprc;
|
|
|
|
u64 vfgptc;
|
|
|
|
u64 vfgorc;
|
|
|
|
u64 vfgotc;
|
|
|
|
u64 vfmprc;
|
2010-03-19 10:59:52 +08:00
|
|
|
|
|
|
|
u64 saved_reset_vfgprc;
|
|
|
|
u64 saved_reset_vfgptc;
|
|
|
|
u64 saved_reset_vfgorc;
|
|
|
|
u64 saved_reset_vfgotc;
|
|
|
|
u64 saved_reset_vfmprc;
|
2010-01-09 10:23:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ixgbevf_info {
|
2015-02-10 19:42:33 +08:00
|
|
|
enum ixgbe_mac_type mac;
|
2012-01-19 06:13:34 +08:00
|
|
|
const struct ixgbe_mac_operations *mac_ops;
|
2010-01-09 10:23:31 +08:00
|
|
|
};
|
|
|
|
|
2014-03-04 11:02:34 +08:00
|
|
|
#define IXGBE_FAILED_READ_REG 0xffffffffU
|
|
|
|
|
|
|
|
#define IXGBE_REMOVED(a) unlikely(!(a))
|
|
|
|
|
2014-03-04 11:02:23 +08:00
|
|
|
static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value)
|
|
|
|
{
|
locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE()
Please do not apply this to mainline directly, instead please re-run the
coccinelle script shown below and apply its output.
For several reasons, it is desirable to use {READ,WRITE}_ONCE() in
preference to ACCESS_ONCE(), and new code is expected to use one of the
former. So far, there's been no reason to change most existing uses of
ACCESS_ONCE(), as these aren't harmful, and changing them results in
churn.
However, for some features, the read/write distinction is critical to
correct operation. To distinguish these cases, separate read/write
accessors must be used. This patch migrates (most) remaining
ACCESS_ONCE() instances to {READ,WRITE}_ONCE(), using the following
coccinelle script:
----
// Convert trivial ACCESS_ONCE() uses to equivalent READ_ONCE() and
// WRITE_ONCE()
// $ make coccicheck COCCI=/home/mark/once.cocci SPFLAGS="--include-headers" MODE=patch
virtual patch
@ depends on patch @
expression E1, E2;
@@
- ACCESS_ONCE(E1) = E2
+ WRITE_ONCE(E1, E2)
@ depends on patch @
expression E;
@@
- ACCESS_ONCE(E)
+ READ_ONCE(E)
----
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: davem@davemloft.net
Cc: linux-arch@vger.kernel.org
Cc: mpe@ellerman.id.au
Cc: shuah@kernel.org
Cc: snitzer@redhat.com
Cc: thor.thayer@linux.intel.com
Cc: tj@kernel.org
Cc: viro@zeniv.linux.org.uk
Cc: will.deacon@arm.com
Link: http://lkml.kernel.org/r/1508792849-3115-19-git-send-email-paulmck@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-10-24 05:07:29 +08:00
|
|
|
u8 __iomem *reg_addr = READ_ONCE(hw->hw_addr);
|
2014-03-04 11:02:40 +08:00
|
|
|
|
|
|
|
if (IXGBE_REMOVED(reg_addr))
|
|
|
|
return;
|
|
|
|
writel(value, reg_addr + reg);
|
2014-03-04 11:02:23 +08:00
|
|
|
}
|
2015-02-10 19:42:33 +08:00
|
|
|
|
2014-03-04 11:02:23 +08:00
|
|
|
#define IXGBE_WRITE_REG(h, r, v) ixgbe_write_reg(h, r, v)
|
|
|
|
|
2014-03-18 15:03:35 +08:00
|
|
|
u32 ixgbevf_read_reg(struct ixgbe_hw *hw, u32 reg);
|
|
|
|
#define IXGBE_READ_REG(h, r) ixgbevf_read_reg(h, r)
|
2014-03-04 11:02:23 +08:00
|
|
|
|
|
|
|
static inline void ixgbe_write_reg_array(struct ixgbe_hw *hw, u32 reg,
|
2015-02-10 19:42:33 +08:00
|
|
|
u32 offset, u32 value)
|
2014-03-04 11:02:23 +08:00
|
|
|
{
|
|
|
|
ixgbe_write_reg(hw, reg + (offset << 2), value);
|
|
|
|
}
|
2015-02-10 19:42:33 +08:00
|
|
|
|
2014-03-04 11:02:23 +08:00
|
|
|
#define IXGBE_WRITE_REG_ARRAY(h, r, o, v) ixgbe_write_reg_array(h, r, o, v)
|
|
|
|
|
|
|
|
static inline u32 ixgbe_read_reg_array(struct ixgbe_hw *hw, u32 reg,
|
2015-02-10 19:42:33 +08:00
|
|
|
u32 offset)
|
2014-03-04 11:02:23 +08:00
|
|
|
{
|
2014-03-18 15:03:35 +08:00
|
|
|
return ixgbevf_read_reg(hw, reg + (offset << 2));
|
2014-03-04 11:02:23 +08:00
|
|
|
}
|
2015-02-10 19:42:33 +08:00
|
|
|
|
2014-03-04 11:02:23 +08:00
|
|
|
#define IXGBE_READ_REG_ARRAY(h, r, o) ixgbe_read_reg_array(h, r, o)
|
|
|
|
|
2012-07-20 16:10:03 +08:00
|
|
|
int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,
|
|
|
|
unsigned int *default_tc);
|
2015-03-31 02:35:26 +08:00
|
|
|
int ixgbevf_get_reta_locked(struct ixgbe_hw *hw, u32 *reta, int num_rx_queues);
|
2015-03-31 02:35:28 +08:00
|
|
|
int ixgbevf_get_rss_key_locked(struct ixgbe_hw *hw, u8 *rss_key);
|
2010-01-09 10:23:31 +08:00
|
|
|
#endif /* __IXGBE_VF_H__ */
|