Skip to content

Commit

Permalink
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/jkirsher/next-queue

Jeff Kirsher says:

====================
100GbE Intel Wired LAN Driver Updates 2016-04-05

This series contains updates to fm10k only.

Bruce provides nearly half of the patches in the series, most of which do
general cleanup of the driver.  These include semantic cleanups,
checkpatch.pl fixes, update driver to use BIT() kernel macro, use
BUILD_BUG_ON() where appropriate and use ether_addr_copy() instead of
memcpy().

Jake provides the remaining patches in the series, starting with a fix
for a possible NULL pointer deference.  Next delays initialization of the
service timer and service task until late in probe().  If we do not wait,
failures in probe do not properly cleanup the service timer or service
task items which result in a kernel panic.  Added better reporting during
error conditions.  Fixed another possible kernel panic where we were
clearing the interrupt scheme before we freed the mailbox IRQ.  Added
helper functions for setting strings and data for ethtool stats.  Fixed
comment mis-spelled words.

v2: Dropped patch 3 from the original submission, until a better solution
    can be worked up based on feedback from Joe Perches and David Miller.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Apr 5, 2016
2 parents 265bee7 + 0ea7fae commit 04c85bf
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 213 deletions.
14 changes: 8 additions & 6 deletions drivers/net/ethernet/intel/fm10k/fm10k.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ struct fm10k_intfc {
unsigned long state;

u32 flags;
#define FM10K_FLAG_RESET_REQUESTED (u32)(1 << 0)
#define FM10K_FLAG_RSS_FIELD_IPV4_UDP (u32)(1 << 1)
#define FM10K_FLAG_RSS_FIELD_IPV6_UDP (u32)(1 << 2)
#define FM10K_FLAG_RX_TS_ENABLED (u32)(1 << 3)
#define FM10K_FLAG_SWPRI_CONFIG (u32)(1 << 4)
#define FM10K_FLAG_DEBUG_STATS (u32)(1 << 5)
#define FM10K_FLAG_RESET_REQUESTED (u32)(BIT(0))
#define FM10K_FLAG_RSS_FIELD_IPV4_UDP (u32)(BIT(1))
#define FM10K_FLAG_RSS_FIELD_IPV6_UDP (u32)(BIT(2))
#define FM10K_FLAG_RX_TS_ENABLED (u32)(BIT(3))
#define FM10K_FLAG_SWPRI_CONFIG (u32)(BIT(4))
#define FM10K_FLAG_DEBUG_STATS (u32)(BIT(5))
int xcast_mode;

/* Tx fast path data */
Expand Down Expand Up @@ -510,6 +510,8 @@ int fm10k_close(struct net_device *netdev);

/* Ethtool */
void fm10k_set_ethtool_ops(struct net_device *dev);
u32 fm10k_get_reta_size(struct net_device *netdev);
void fm10k_write_reta(struct fm10k_intfc *interface, const u32 *indir);

/* IOV */
s32 fm10k_iov_event(struct fm10k_intfc *interface);
Expand Down
223 changes: 115 additions & 108 deletions drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,57 +153,51 @@ static const char fm10k_prv_flags[FM10K_PRV_FLAG_LEN][ETH_GSTRING_LEN] = {
"debug-statistics",
};

static void fm10k_add_stat_strings(char **p, const char *prefix,
const struct fm10k_stats stats[],
const unsigned int size)
{
unsigned int i;

for (i = 0; i < size; i++) {
snprintf(*p, ETH_GSTRING_LEN, "%s%s",
prefix, stats[i].stat_string);
*p += ETH_GSTRING_LEN;
}
}

static void fm10k_get_stat_strings(struct net_device *dev, u8 *data)
{
struct fm10k_intfc *interface = netdev_priv(dev);
struct fm10k_iov_data *iov_data = interface->iov_data;
char *p = (char *)data;
unsigned int i;
unsigned int j;

for (i = 0; i < FM10K_NETDEV_STATS_LEN; i++) {
memcpy(p, fm10k_gstrings_net_stats[i].stat_string,
ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
}
fm10k_add_stat_strings(&p, "", fm10k_gstrings_net_stats,
FM10K_NETDEV_STATS_LEN);

for (i = 0; i < FM10K_GLOBAL_STATS_LEN; i++) {
memcpy(p, fm10k_gstrings_global_stats[i].stat_string,
ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
}
fm10k_add_stat_strings(&p, "", fm10k_gstrings_global_stats,
FM10K_GLOBAL_STATS_LEN);

if (interface->flags & FM10K_FLAG_DEBUG_STATS) {
for (i = 0; i < FM10K_DEBUG_STATS_LEN; i++) {
memcpy(p, fm10k_gstrings_debug_stats[i].stat_string,
ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
}
}
if (interface->flags & FM10K_FLAG_DEBUG_STATS)
fm10k_add_stat_strings(&p, "", fm10k_gstrings_debug_stats,
FM10K_DEBUG_STATS_LEN);

for (i = 0; i < FM10K_MBX_STATS_LEN; i++) {
memcpy(p, fm10k_gstrings_mbx_stats[i].stat_string,
ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
}
fm10k_add_stat_strings(&p, "", fm10k_gstrings_mbx_stats,
FM10K_MBX_STATS_LEN);

if (interface->hw.mac.type != fm10k_mac_vf) {
for (i = 0; i < FM10K_PF_STATS_LEN; i++) {
memcpy(p, fm10k_gstrings_pf_stats[i].stat_string,
ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
}
}
if (interface->hw.mac.type != fm10k_mac_vf)
fm10k_add_stat_strings(&p, "", fm10k_gstrings_pf_stats,
FM10K_PF_STATS_LEN);

if ((interface->flags & FM10K_FLAG_DEBUG_STATS) && iov_data) {
for (i = 0; i < iov_data->num_vfs; i++) {
for (j = 0; j < FM10K_MBX_STATS_LEN; j++) {
snprintf(p,
ETH_GSTRING_LEN,
"vf_%u_%s", i,
fm10k_gstrings_mbx_stats[j].stat_string);
p += ETH_GSTRING_LEN;
}
char prefix[ETH_GSTRING_LEN];

snprintf(prefix, ETH_GSTRING_LEN, "vf_%u_", i);
fm10k_add_stat_strings(&p, prefix,
fm10k_gstrings_mbx_stats,
FM10K_MBX_STATS_LEN);
}
}

Expand Down Expand Up @@ -271,6 +265,41 @@ static int fm10k_get_sset_count(struct net_device *dev, int sset)
}
}

static void fm10k_add_ethtool_stats(u64 **data, void *pointer,
const struct fm10k_stats stats[],
const unsigned int size)
{
unsigned int i;
char *p;

/* simply skip forward if we were not given a valid pointer */
if (!pointer) {
*data += size;
return;
}

for (i = 0; i < size; i++) {
p = (char *)pointer + stats[i].stat_offset;

switch (stats[i].sizeof_stat) {
case sizeof(u64):
*((*data)++) = *(u64 *)p;
break;
case sizeof(u32):
*((*data)++) = *(u32 *)p;
break;
case sizeof(u16):
*((*data)++) = *(u16 *)p;
break;
case sizeof(u8):
*((*data)++) = *(u8 *)p;
break;
default:
*((*data)++) = 0;
}
}
}

static void fm10k_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats __always_unused *stats,
u64 *data)
Expand All @@ -279,47 +308,29 @@ static void fm10k_get_ethtool_stats(struct net_device *netdev,
struct fm10k_intfc *interface = netdev_priv(netdev);
struct fm10k_iov_data *iov_data = interface->iov_data;
struct net_device_stats *net_stats = &netdev->stats;
char *p;
int i, j;

fm10k_update_stats(interface);

for (i = 0; i < FM10K_NETDEV_STATS_LEN; i++) {
p = (char *)net_stats + fm10k_gstrings_net_stats[i].stat_offset;
*(data++) = (fm10k_gstrings_net_stats[i].sizeof_stat ==
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
}
fm10k_add_ethtool_stats(&data, net_stats, fm10k_gstrings_net_stats,
FM10K_NETDEV_STATS_LEN);

for (i = 0; i < FM10K_GLOBAL_STATS_LEN; i++) {
p = (char *)interface +
fm10k_gstrings_global_stats[i].stat_offset;
*(data++) = (fm10k_gstrings_global_stats[i].sizeof_stat ==
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
}
fm10k_add_ethtool_stats(&data, interface, fm10k_gstrings_global_stats,
FM10K_GLOBAL_STATS_LEN);

if (interface->flags & FM10K_FLAG_DEBUG_STATS) {
for (i = 0; i < FM10K_DEBUG_STATS_LEN; i++) {
p = (char *)interface +
fm10k_gstrings_debug_stats[i].stat_offset;
*(data++) = (fm10k_gstrings_debug_stats[i].sizeof_stat ==
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
}
}
if (interface->flags & FM10K_FLAG_DEBUG_STATS)
fm10k_add_ethtool_stats(&data, interface,
fm10k_gstrings_debug_stats,
FM10K_DEBUG_STATS_LEN);

for (i = 0; i < FM10K_MBX_STATS_LEN; i++) {
p = (char *)&interface->hw.mbx +
fm10k_gstrings_mbx_stats[i].stat_offset;
*(data++) = (fm10k_gstrings_mbx_stats[i].sizeof_stat ==
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
}
fm10k_add_ethtool_stats(&data, &interface->hw.mbx,
fm10k_gstrings_mbx_stats,
FM10K_MBX_STATS_LEN);

if (interface->hw.mac.type != fm10k_mac_vf) {
for (i = 0; i < FM10K_PF_STATS_LEN; i++) {
p = (char *)interface +
fm10k_gstrings_pf_stats[i].stat_offset;
*(data++) = (fm10k_gstrings_pf_stats[i].sizeof_stat ==
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
}
fm10k_add_ethtool_stats(&data, interface,
fm10k_gstrings_pf_stats,
FM10K_PF_STATS_LEN);
}

if ((interface->flags & FM10K_FLAG_DEBUG_STATS) && iov_data) {
Expand All @@ -328,18 +339,9 @@ static void fm10k_get_ethtool_stats(struct net_device *netdev,

vf_info = &iov_data->vf_info[i];

/* skip stats if we don't have a vf info */
if (!vf_info) {
data += FM10K_MBX_STATS_LEN;
continue;
}

for (j = 0; j < FM10K_MBX_STATS_LEN; j++) {
p = (char *)&vf_info->mbx +
fm10k_gstrings_mbx_stats[j].stat_offset;
*(data++) = (fm10k_gstrings_mbx_stats[j].sizeof_stat ==
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
}
fm10k_add_ethtool_stats(&data, &vf_info->mbx,
fm10k_gstrings_mbx_stats,
FM10K_MBX_STATS_LEN);
}
}

Expand Down Expand Up @@ -425,7 +427,7 @@ static void fm10k_get_regs(struct net_device *netdev,
u32 *buff = p;
u16 i;

regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id;
regs->version = BIT(24) | (hw->revision_id << 16) | hw->device_id;

switch (hw->mac.type) {
case fm10k_mac_pf:
Expand Down Expand Up @@ -935,15 +937,15 @@ static int fm10k_mbx_test(struct fm10k_intfc *interface, u64 *data)
struct fm10k_mbx_info *mbx = &hw->mbx;
u32 attr_flag, test_msg[6];
unsigned long timeout;
int err;
int err = -EINVAL;

/* For now this is a VF only feature */
if (hw->mac.type != fm10k_mac_vf)
return 0;

/* loop through both nested and unnested attribute types */
for (attr_flag = (1 << FM10K_TEST_MSG_UNSET);
attr_flag < (1 << (2 * FM10K_TEST_MSG_NESTED));
for (attr_flag = BIT(FM10K_TEST_MSG_UNSET);
attr_flag < BIT(2 * FM10K_TEST_MSG_NESTED);
attr_flag += attr_flag) {
/* generate message to be tested */
fm10k_tlv_msg_test_create(test_msg, attr_flag);
Expand Down Expand Up @@ -1005,7 +1007,7 @@ static u32 fm10k_get_priv_flags(struct net_device *netdev)
u32 priv_flags = 0;

if (interface->flags & FM10K_FLAG_DEBUG_STATS)
priv_flags |= 1 << FM10K_PRV_FLAG_DEBUG_STATS;
priv_flags |= BIT(FM10K_PRV_FLAG_DEBUG_STATS);

return priv_flags;
}
Expand All @@ -1014,22 +1016,42 @@ static int fm10k_set_priv_flags(struct net_device *netdev, u32 priv_flags)
{
struct fm10k_intfc *interface = netdev_priv(netdev);

if (priv_flags >= (1 << FM10K_PRV_FLAG_LEN))
if (priv_flags >= BIT(FM10K_PRV_FLAG_LEN))
return -EINVAL;

if (priv_flags & (1 << FM10K_PRV_FLAG_DEBUG_STATS))
if (priv_flags & BIT(FM10K_PRV_FLAG_DEBUG_STATS))
interface->flags |= FM10K_FLAG_DEBUG_STATS;
else
interface->flags &= ~FM10K_FLAG_DEBUG_STATS;

return 0;
}

static u32 fm10k_get_reta_size(struct net_device __always_unused *netdev)
u32 fm10k_get_reta_size(struct net_device __always_unused *netdev)
{
return FM10K_RETA_SIZE * FM10K_RETA_ENTRIES_PER_REG;
}

void fm10k_write_reta(struct fm10k_intfc *interface, const u32 *indir)
{
struct fm10k_hw *hw = &interface->hw;
int i;

/* record entries to reta table */
for (i = 0; i < FM10K_RETA_SIZE; i++, indir += 4) {
u32 reta = indir[0] |
(indir[1] << 8) |
(indir[2] << 16) |
(indir[3] << 24);

if (interface->reta[i] == reta)
continue;

interface->reta[i] = reta;
fm10k_write_reg(hw, FM10K_RETA(0, i), reta);
}
}

static int fm10k_get_reta(struct net_device *netdev, u32 *indir)
{
struct fm10k_intfc *interface = netdev_priv(netdev);
Expand All @@ -1053,7 +1075,6 @@ static int fm10k_get_reta(struct net_device *netdev, u32 *indir)
static int fm10k_set_reta(struct net_device *netdev, const u32 *indir)
{
struct fm10k_intfc *interface = netdev_priv(netdev);
struct fm10k_hw *hw = &interface->hw;
int i;
u16 rss_i;

Expand All @@ -1068,19 +1089,7 @@ static int fm10k_set_reta(struct net_device *netdev, const u32 *indir)
return -EINVAL;
}

/* record entries to reta table */
for (i = 0; i < FM10K_RETA_SIZE; i++, indir += 4) {
u32 reta = indir[0] |
(indir[1] << 8) |
(indir[2] << 16) |
(indir[3] << 24);

if (interface->reta[i] == reta)
continue;

interface->reta[i] = reta;
fm10k_write_reg(hw, FM10K_RETA(0, i), reta);
}
fm10k_write_reta(interface, indir);

return 0;
}
Expand Down Expand Up @@ -1145,7 +1154,7 @@ static unsigned int fm10k_max_channels(struct net_device *dev)

/* For QoS report channels per traffic class */
if (tcs > 1)
max_combined = 1 << (fls(max_combined / tcs) - 1);
max_combined = BIT((fls(max_combined / tcs) - 1));

return max_combined;
}
Expand Down Expand Up @@ -1210,11 +1219,9 @@ static int fm10k_get_ts_info(struct net_device *dev,
else
info->phc_index = -1;

info->tx_types = (1 << HWTSTAMP_TX_OFF) |
(1 << HWTSTAMP_TX_ON);
info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON);

info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
(1 << HWTSTAMP_FILTER_ALL);
info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/intel/fm10k/fm10k_iov.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ s32 fm10k_iov_event(struct fm10k_intfc *interface)
s64 vflre;
int i;

/* if there is no iov_data then there is no mailboxes to process */
/* if there is no iov_data then there is no mailbox to process */
if (!ACCESS_ONCE(interface->iov_data))
return 0;

Expand Down Expand Up @@ -98,7 +98,7 @@ s32 fm10k_iov_mbx(struct fm10k_intfc *interface)
struct fm10k_iov_data *iov_data;
int i;

/* if there is no iov_data then there is no mailboxes to process */
/* if there is no iov_data then there is no mailbox to process */
if (!ACCESS_ONCE(interface->iov_data))
return 0;

Expand Down
Loading

0 comments on commit 04c85bf

Please sign in to comment.