Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 009f33ed authored by David S. Miller's avatar David S. Miller
Browse files


Jeff Kirsher says:

====================
Intel Wired LAN Driver Updates 2015-02-24

This series contains updates to i40e and i40evf only, which bumps their
versions to i40e 1.2.9 and i40evf 1.2.3.

Paul fixes i40e_debug_aq() for big endian machines by adding the
appropriate LExx_TO_CPU wrappers.

Catherine adds a requested speed variable to the link_status to store the
last speeds we requested from the firmware and use the advertised speed
settings in get_settings in ethtool now that we have it.  Due to the
new code addition, she also refactors get_settings to improve readability
and to accommodate some of the longer lines of code by adding two
functions i40e_get_settings_link_up() and i40e_get_settings_link_down().

Carolyn adds a struct to the VSI struct to keep track of RXNFC settings
done via ethtool.  Adds more information to the interrupt vector
names, specifically to the VF misc vector name so that we can distinguish
between all the interrupts.

Ashish enables the i40evf driver to enable debug prints via ethtool.

Mitch updates i40e to enable packet split only when IOMMU is in use,
since it shows a distinct advantage over the single-buffer path
because it minimizes DMA mapping and unmapping.  Also adds the receive
routine in use to the features log message to be able to print the
receive packet split status.

Greg adds the ability to get, set and commit permanently the NPAR
partition BW configuration through configfs.  Enables an application
to query the i40e driver's private flags to get the status of NPAR
enablement via ethtool.

Neerav adds support for bridge offload ndo_ops getlink and setlink
to enable bridge hardware mode as per the mode set via IFLA_BRIDGE_MODE.
The support is only enabled in the case of a PF VSI and not available for
any other VSI type.

Kevin fixes i40e by ensuring the BUF and FLAG_RD flags are set for
indirect admin queue command.

Vasu updates the driver to setup FCoE netdev device type as "fcoe", so that
it shows up in sysfs as FCoE device.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents d79d2107 5b8eb176
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
################################################################################
#
# Intel Ethernet Controller XL710 Family Linux Driver
# Copyright(c) 2013 - 2014 Intel Corporation.
# Copyright(c) 2013 - 2015 Intel Corporation.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms and conditions of the GNU General Public License,
@@ -37,6 +37,7 @@ i40e-objs := i40e_main.o \
	i40e_hmc.o	\
	i40e_lan_hmc.o	\
	i40e_nvm.o	\
	i40e_configfs.o	\
	i40e_debugfs.o	\
	i40e_diag.o	\
	i40e_txrx.o	\
+22 −2
Original line number Diff line number Diff line
/*******************************************************************************
 *
 * Intel Ethernet Controller XL710 Family Linux Driver
 * Copyright(c) 2013 - 2014 Intel Corporation.
 * Copyright(c) 2013 - 2015 Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
@@ -36,6 +36,7 @@
#include <linux/aer.h>
#include <linux/netdevice.h>
#include <linux/ioport.h>
#include <linux/iommu.h>
#include <linux/slab.h>
#include <linux/list.h>
#include <linux/string.h>
@@ -49,6 +50,7 @@
#include <net/ip6_checksum.h>
#include <linux/ethtool.h>
#include <linux/if_vlan.h>
#include <linux/if_bridge.h>
#include <linux/clocksource.h>
#include <linux/net_tstamp.h>
#include <linux/ptp_clock_kernel.h>
@@ -94,6 +96,9 @@
#define I40E_QUEUE_WAIT_RETRY_LIMIT   10
#define I40E_INT_NAME_STR_LEN        (IFNAMSIZ + 9)

/* Ethtool Private Flags */
#define I40E_PRIV_FLAGS_NPAR_FLAG	(1 << 0)

#define I40E_NVM_VERSION_LO_SHIFT  0
#define I40E_NVM_VERSION_LO_MASK   (0xff << I40E_NVM_VERSION_LO_SHIFT)
#define I40E_NVM_VERSION_HI_SHIFT  12
@@ -384,6 +389,9 @@ struct i40e_pf {
	bool ptp_tx;
	bool ptp_rx;
	u16 rss_table_size;
	/* These are only valid in NPAR modes */
	u32 npar_max_bw;
	u32 npar_min_bw;
};

struct i40e_mac_filter {
@@ -406,6 +414,7 @@ struct i40e_veb {
	u16 uplink_seid;
	u16 stats_idx;           /* index of VEB parent */
	u8  enabled_tc;
	u16 bridge_mode;	/* Bridge Mode (VEB/VEPA) */
	u16 flags;
	u16 bw_limit;
	u8  bw_max_quanta;
@@ -505,6 +514,9 @@ struct i40e_vsi {

	/* VSI specific handlers */
	irqreturn_t (*irq_handler)(int irq, void *data);

	/* current rxnfc data */
	struct ethtool_rxnfc rxnfc; /* current rss hash opts */
} ____cacheline_internodealigned_in_smp;

struct i40e_netdev_priv {
@@ -681,6 +693,7 @@ int i40e_vlan_rx_add_vid(struct net_device *netdev,
int i40e_vlan_rx_kill_vid(struct net_device *netdev,
			  __always_unused __be16 proto, u16 vid);
#endif
int i40e_open(struct net_device *netdev);
int i40e_vsi_open(struct i40e_vsi *vsi);
void i40e_vlan_stripping_disable(struct i40e_vsi *vsi);
int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid);
@@ -691,7 +704,6 @@ bool i40e_is_vsi_in_vlan(struct i40e_vsi *vsi);
struct i40e_mac_filter *i40e_find_mac(struct i40e_vsi *vsi, u8 *macaddr,
				      bool is_vf, bool is_netdev);
#ifdef I40E_FCOE
int i40e_open(struct net_device *netdev);
int i40e_close(struct net_device *netdev);
int i40e_setup_tc(struct net_device *netdev, u8 tc);
void i40e_netpoll(struct net_device *netdev);
@@ -728,4 +740,12 @@ int i40e_ptp_set_ts_config(struct i40e_pf *pf, struct ifreq *ifr);
int i40e_ptp_get_ts_config(struct i40e_pf *pf, struct ifreq *ifr);
void i40e_ptp_init(struct i40e_pf *pf);
void i40e_ptp_stop(struct i40e_pf *pf);
int i40e_is_vsi_uplink_mode_veb(struct i40e_vsi *vsi);
#if IS_ENABLED(CONFIG_CONFIGFS_FS)
int i40e_configfs_init(void);
void i40e_configfs_exit(void);
#endif /* CONFIG_CONFIGFS_FS */
i40e_status i40e_get_npar_bw_setting(struct i40e_pf *pf);
i40e_status i40e_set_npar_bw_setting(struct i40e_pf *pf);
i40e_status i40e_commit_npar_bw_setting(struct i40e_pf *pf);
#endif /* _I40E_H_ */
+137 −13
Original line number Diff line number Diff line
/*******************************************************************************
 *
 * Intel Ethernet Controller XL710 Family Linux Driver
 * Copyright(c) 2013 - 2014 Intel Corporation.
 * Copyright(c) 2013 - 2015 Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
@@ -94,16 +94,19 @@ void i40e_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc,

	i40e_debug(hw, mask,
		   "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
		   aq_desc->opcode, aq_desc->flags, aq_desc->datalen,
		   aq_desc->retval);
		   le16_to_cpu(aq_desc->opcode),
		   le16_to_cpu(aq_desc->flags),
		   le16_to_cpu(aq_desc->datalen),
		   le16_to_cpu(aq_desc->retval));
	i40e_debug(hw, mask, "\tcookie (h,l) 0x%08X 0x%08X\n",
		   aq_desc->cookie_high, aq_desc->cookie_low);
		   le32_to_cpu(aq_desc->cookie_high),
		   le32_to_cpu(aq_desc->cookie_low));
	i40e_debug(hw, mask, "\tparam (0,1)  0x%08X 0x%08X\n",
		   aq_desc->params.internal.param0,
		   aq_desc->params.internal.param1);
		   le32_to_cpu(aq_desc->params.internal.param0),
		   le32_to_cpu(aq_desc->params.internal.param1));
	i40e_debug(hw, mask, "\taddr (h,l)   0x%08X 0x%08X\n",
		   aq_desc->params.external.addr_high,
		   aq_desc->params.external.addr_low);
		   le32_to_cpu(aq_desc->params.external.addr_high),
		   le32_to_cpu(aq_desc->params.external.addr_low));

	if ((buffer != NULL) && (aq_desc->datalen != 0)) {
		memset(data, 0, sizeof(data));
@@ -116,15 +119,19 @@ void i40e_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc,
			if ((i % 16) == 15) {
				i40e_debug(hw, mask,
					   "\t0x%04X  %08X %08X %08X %08X\n",
					   i - 15, data[0], data[1], data[2],
					   data[3]);
					   i - 15, le32_to_cpu(data[0]),
					   le32_to_cpu(data[1]),
					   le32_to_cpu(data[2]),
					   le32_to_cpu(data[3]));
				memset(data, 0, sizeof(data));
			}
		}
		if ((i % 16) != 0)
			i40e_debug(hw, mask, "\t0x%04X  %08X %08X %08X %08X\n",
				   i - (i % 16), data[0], data[1], data[2],
				   data[3]);
				   i - (i % 16), le32_to_cpu(data[0]),
				   le32_to_cpu(data[1]),
				   le32_to_cpu(data[2]),
				   le32_to_cpu(data[3]));
	}
}

@@ -1787,7 +1794,7 @@ i40e_status i40e_aq_send_driver_version(struct i40e_hw *hw,

	i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_driver_version);

	desc.flags |= cpu_to_le16(I40E_AQ_FLAG_SI);
	desc.flags |= cpu_to_le16(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD);
	cmd->driver_major_ver = dv->major_version;
	cmd->driver_minor_ver = dv->minor_version;
	cmd->driver_build_ver = dv->build_version;
@@ -3346,6 +3353,47 @@ i40e_status i40e_aq_add_rem_control_packet_filter(struct i40e_hw *hw,
	return status;
}

/**
 * i40e_aq_alternate_read
 * @hw: pointer to the hardware structure
 * @reg_addr0: address of first dword to be read
 * @reg_val0: pointer for data read from 'reg_addr0'
 * @reg_addr1: address of second dword to be read
 * @reg_val1: pointer for data read from 'reg_addr1'
 *
 * Read one or two dwords from alternate structure. Fields are indicated
 * by 'reg_addr0' and 'reg_addr1' register numbers. If 'reg_val1' pointer
 * is not passed then only register at 'reg_addr0' is read.
 *
 **/
i40e_status i40e_aq_alternate_read(struct i40e_hw *hw,
				   u32 reg_addr0, u32 *reg_val0,
				   u32 reg_addr1, u32 *reg_val1)
{
	struct i40e_aq_desc desc;
	struct i40e_aqc_alternate_write *cmd_resp =
		(struct i40e_aqc_alternate_write *)&desc.params.raw;
	i40e_status status;

	if (!reg_val0)
		return I40E_ERR_PARAM;

	i40e_fill_default_direct_cmd_desc(&desc, i40e_aqc_opc_alternate_read);
	cmd_resp->address0 = cpu_to_le32(reg_addr0);
	cmd_resp->address1 = cpu_to_le32(reg_addr1);

	status = i40e_asq_send_command(hw, &desc, NULL, 0, NULL);

	if (!status) {
		*reg_val0 = le32_to_cpu(cmd_resp->data0);

		if (reg_val1)
			*reg_val1 = le32_to_cpu(cmd_resp->data1);
	}

	return status;
}

/**
 * i40e_aq_resume_port_tx
 * @hw: pointer to the hardware structure
@@ -3410,3 +3458,79 @@ void i40e_set_pci_config_data(struct i40e_hw *hw, u16 link_status)
		break;
	}
}

/**
 * i40e_read_bw_from_alt_ram
 * @hw: pointer to the hardware structure
 * @max_bw: pointer for max_bw read
 * @min_bw: pointer for min_bw read
 * @min_valid: pointer for bool that is true if min_bw is a valid value
 * @max_valid: pointer for bool that is true if max_bw is a valid value
 *
 * Read bw from the alternate ram for the given pf
 **/
i40e_status i40e_read_bw_from_alt_ram(struct i40e_hw *hw,
				      u32 *max_bw, u32 *min_bw,
				      bool *min_valid, bool *max_valid)
{
	i40e_status status;
	u32 max_bw_addr, min_bw_addr;

	/* Calculate the address of the min/max bw registers */
	max_bw_addr = I40E_ALT_STRUCT_FIRST_PF_OFFSET +
		      I40E_ALT_STRUCT_MAX_BW_OFFSET +
		      (I40E_ALT_STRUCT_DWORDS_PER_PF * hw->pf_id);
	min_bw_addr = I40E_ALT_STRUCT_FIRST_PF_OFFSET +
		      I40E_ALT_STRUCT_MIN_BW_OFFSET +
		      (I40E_ALT_STRUCT_DWORDS_PER_PF * hw->pf_id);

	/* Read the bandwidths from alt ram */
	status = i40e_aq_alternate_read(hw, max_bw_addr, max_bw,
					min_bw_addr, min_bw);

	if (*min_bw & I40E_ALT_BW_VALID_MASK)
		*min_valid = true;
	else
		*min_valid = false;

	if (*max_bw & I40E_ALT_BW_VALID_MASK)
		*max_valid = true;
	else
		*max_valid = false;

	return status;
}

/**
 * i40e_aq_configure_partition_bw
 * @hw: pointer to the hardware structure
 * @bw_data: Buffer holding valid pfs and bw limits
 * @cmd_details: pointer to command details
 *
 * Configure partitions guaranteed/max bw
 **/
i40e_status i40e_aq_configure_partition_bw(struct i40e_hw *hw,
			struct i40e_aqc_configure_partition_bw_data *bw_data,
			struct i40e_asq_cmd_details *cmd_details)
{
	i40e_status status;
	struct i40e_aq_desc desc;
	u16 bwd_size = sizeof(*bw_data);

	i40e_fill_default_direct_cmd_desc(&desc,
					  i40e_aqc_opc_configure_partition_bw);

	/* Indirect command */
	desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
	desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_RD);

	if (bwd_size > I40E_AQ_LARGE_BUF)
		desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);

	desc.datalen = cpu_to_le16(bwd_size);

	status = i40e_asq_send_command(hw, &desc, bw_data, bwd_size,
				       cmd_details);

	return status;
}
+354 −0
Original line number Diff line number Diff line
/*******************************************************************************
 *
 * Intel Ethernet Controller XL710 Family Linux Driver
 * Copyright(c) 2013 - 2015 Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * The full GNU General Public License is included in this distribution in
 * the file called "COPYING".
 *
 * Contact Information:
 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 *
 ******************************************************************************/

#include <linux/configfs.h>
#include "i40e.h"

#if IS_ENABLED(CONFIG_CONFIGFS_FS)

/**
 * configfs structure for i40e
 *
 * This file adds code for configfs support for the i40e driver.  This sets
 * up a filesystem under /sys/kernel/config in which configuration changes
 * can be made for the driver's netdevs.
 *
 * The initialization in this code creates the "i40e" entry in the configfs
 * system.  After that, the user needs to use mkdir to create configurations
 * for specific netdev ports; for example "mkdir eth3".  This code will verify
 * that such a netdev exists and that it is owned by i40e.
 *
 **/

struct i40e_cfgfs_vsi {
	struct config_item item;
	struct i40e_vsi *vsi;
};

static inline struct i40e_cfgfs_vsi *to_i40e_cfgfs_vsi(struct config_item *item)
{
	return item ? container_of(item, struct i40e_cfgfs_vsi, item) : NULL;
}

static struct configfs_attribute i40e_cfgfs_vsi_attr_min_bw = {
	.ca_owner = THIS_MODULE,
	.ca_name = "min_bw",
	.ca_mode = S_IRUGO | S_IWUSR,
};

static struct configfs_attribute i40e_cfgfs_vsi_attr_max_bw = {
	.ca_owner = THIS_MODULE,
	.ca_name = "max_bw",
	.ca_mode = S_IRUGO | S_IWUSR,
};

static struct configfs_attribute i40e_cfgfs_vsi_attr_commit = {
	.ca_owner = THIS_MODULE,
	.ca_name = "commit",
	.ca_mode = S_IRUGO | S_IWUSR,
};

static struct configfs_attribute i40e_cfgfs_vsi_attr_port_count = {
	.ca_owner = THIS_MODULE,
	.ca_name = "ports",
	.ca_mode = S_IRUGO | S_IWUSR,
};

static struct configfs_attribute i40e_cfgfs_vsi_attr_part_count = {
	.ca_owner = THIS_MODULE,
	.ca_name = "partitions",
	.ca_mode = S_IRUGO | S_IWUSR,
};

static struct configfs_attribute *i40e_cfgfs_vsi_attrs[] = {
	&i40e_cfgfs_vsi_attr_min_bw,
	&i40e_cfgfs_vsi_attr_max_bw,
	&i40e_cfgfs_vsi_attr_commit,
	&i40e_cfgfs_vsi_attr_port_count,
	&i40e_cfgfs_vsi_attr_part_count,
	NULL,
};

/**
 * i40e_cfgfs_vsi_attr_show - Show a VSI's NPAR BW partition info
 * @item: A pointer back to the configfs item created on driver load
 * @attr: A pointer to this item's configuration attribute
 * @page: A pointer to the output buffer
 **/
static ssize_t i40e_cfgfs_vsi_attr_show(struct config_item *item,
					struct configfs_attribute *attr,
					char *page)
{
	struct i40e_cfgfs_vsi *i40e_cfgfs_vsi = to_i40e_cfgfs_vsi(item);
	struct i40e_pf *pf = i40e_cfgfs_vsi->vsi->back;
	ssize_t count;

	if (i40e_cfgfs_vsi->vsi != pf->vsi[pf->lan_vsi])
		return 0;

	if (strncmp(attr->ca_name, "min_bw", 6) == 0)
		count = sprintf(page, "%s %s %d%%\n",
				i40e_cfgfs_vsi->vsi->netdev->name,
				(pf->npar_min_bw & I40E_ALT_BW_RELATIVE_MASK) ?
				"Relative Min BW" : "Absolute Min BW",
				pf->npar_min_bw & I40E_ALT_BW_VALUE_MASK);
	else if (strncmp(attr->ca_name, "max_bw", 6) == 0)
		count = sprintf(page, "%s %s %d%%\n",
				i40e_cfgfs_vsi->vsi->netdev->name,
				(pf->npar_max_bw & I40E_ALT_BW_RELATIVE_MASK) ?
				"Relative Max BW" : "Absolute Max BW",
				pf->npar_max_bw & I40E_ALT_BW_VALUE_MASK);
	else if (strncmp(attr->ca_name, "ports", 5) == 0)
		count = sprintf(page, "%d\n",
				pf->hw.num_ports);
	else if (strncmp(attr->ca_name, "partitions", 10) == 0)
		count = sprintf(page, "%d\n",
				pf->hw.num_partitions);
	else
		return 0;

	return count;
}

/**
 * i40e_cfgfs_vsi_attr_store - Show a VSI's NPAR BW partition info
 * @item: A pointer back to the configfs item created on driver load
 * @attr: A pointer to this item's configuration attribute
 * @page: A pointer to the user input buffer holding the user input values
 **/
static ssize_t i40e_cfgfs_vsi_attr_store(struct config_item *item,
					 struct configfs_attribute *attr,
					 const char *page, size_t count)
{
	struct i40e_cfgfs_vsi *i40e_cfgfs_vsi = to_i40e_cfgfs_vsi(item);
	struct i40e_pf *pf = i40e_cfgfs_vsi->vsi->back;
	char *p = (char *)page;
	int rc;
	unsigned long tmp;

	if (i40e_cfgfs_vsi->vsi != pf->vsi[pf->lan_vsi])
		return 0;

	if (!p || (*p && (*p == '\n')))
		return -EINVAL;

	rc = kstrtoul(p, 10, &tmp);
	if (rc)
		return rc;
	if (tmp > 100)
		return -ERANGE;

	if (strncmp(attr->ca_name, "min_bw", 6) == 0) {
		if (tmp > (pf->npar_max_bw & I40E_ALT_BW_VALUE_MASK))
			return -ERANGE;
		/* Preserve the valid and relative BW bits - the rest is
		 * don't care.
		 */
		pf->npar_min_bw &= (I40E_ALT_BW_RELATIVE_MASK |
				    I40E_ALT_BW_VALID_MASK);
		pf->npar_min_bw |= (tmp & I40E_ALT_BW_VALUE_MASK);
		i40e_set_npar_bw_setting(pf);
	} else if (strncmp(attr->ca_name, "max_bw", 6) == 0) {
		if (tmp < 1 ||
		    tmp < (pf->npar_min_bw & I40E_ALT_BW_VALUE_MASK))
			return -ERANGE;
		/* Preserve the valid and relative BW bits - the rest is
		 * don't care.
		 */
		pf->npar_max_bw &= (I40E_ALT_BW_RELATIVE_MASK |
				    I40E_ALT_BW_VALID_MASK);
		pf->npar_max_bw |= (tmp & I40E_ALT_BW_VALUE_MASK);
		i40e_set_npar_bw_setting(pf);
	} else if (strncmp(attr->ca_name, "commit", 6) == 0 && tmp == 1) {
		if (i40e_commit_npar_bw_setting(pf))
			return -EIO;
	}

	return count;
}

/**
 * i40e_cfgfs_vsi_release - Free up the configuration item memory
 * @item: A pointer back to the configfs item created on driver load
 **/
static void i40e_cfgfs_vsi_release(struct config_item *item)
{
	kfree(to_i40e_cfgfs_vsi(item));
}

static struct configfs_item_operations i40e_cfgfs_vsi_item_ops = {
	.release		= i40e_cfgfs_vsi_release,
	.show_attribute		= i40e_cfgfs_vsi_attr_show,
	.store_attribute	= i40e_cfgfs_vsi_attr_store,
};

static struct config_item_type i40e_cfgfs_vsi_type = {
	.ct_item_ops	= &i40e_cfgfs_vsi_item_ops,
	.ct_attrs	= i40e_cfgfs_vsi_attrs,
	.ct_owner	= THIS_MODULE,
};

struct i40e_cfgfs_group {
	struct config_group group;
};

/**
 * to_i40e_cfgfs_group - Get the group pointer from the config item
 * @item: A pointer back to the configfs item created on driver load
 **/
static inline struct i40e_cfgfs_group *
to_i40e_cfgfs_group(struct config_item *item)
{
	return item ? container_of(to_config_group(item),
				   struct i40e_cfgfs_group, group) : NULL;
}

/**
 * i40e_cfgfs_group_make_item - Create the configfs item with group container
 * @group: A pointer to our configfs group
 * @name: A pointer to the nume of the device we're looking for
 **/
static struct config_item *
i40e_cfgfs_group_make_item(struct config_group *group, const char *name)
{
	struct i40e_cfgfs_vsi *i40e_cfgfs_vsi;
	struct net_device *netdev;
	struct i40e_netdev_priv *np;

	read_lock(&dev_base_lock);
	netdev = first_net_device(&init_net);
	while (netdev) {
		if (strncmp(netdev->name, name, sizeof(netdev->name)) == 0)
			break;
		netdev = next_net_device(netdev);
	}
	read_unlock(&dev_base_lock);

	if (!netdev)
		return ERR_PTR(-ENODEV);

	/* is this netdev owned by i40e? */
	if (netdev->netdev_ops->ndo_open != i40e_open)
		return ERR_PTR(-EACCES);

	i40e_cfgfs_vsi = kzalloc(sizeof(*i40e_cfgfs_vsi), GFP_KERNEL);
	if (!i40e_cfgfs_vsi)
		return ERR_PTR(-ENOMEM);

	np = netdev_priv(netdev);
	i40e_cfgfs_vsi->vsi = np->vsi;
	config_item_init_type_name(&i40e_cfgfs_vsi->item, name,
				   &i40e_cfgfs_vsi_type);

	return &i40e_cfgfs_vsi->item;
}

static struct configfs_attribute i40e_cfgfs_group_attr_description = {
	.ca_owner = THIS_MODULE,
	.ca_name = "description",
	.ca_mode = S_IRUGO,
};

static struct configfs_attribute *i40e_cfgfs_group_attrs[] = {
	&i40e_cfgfs_group_attr_description,
	NULL,
};

static ssize_t i40e_cfgfs_group_attr_show(struct config_item *item,
					  struct configfs_attribute *attr,
					  char *page)
{
	return sprintf(page,
"i40e\n"
"\n"
"This subsystem allows the modification of network port configurations.\n"
"To start, use the name of the network port to be configured in a 'mkdir'\n"
"command, e.g. 'mkdir eth3'.\n");
}

static void i40e_cfgfs_group_release(struct config_item *item)
{
	kfree(to_i40e_cfgfs_group(item));
}

static struct configfs_item_operations i40e_cfgfs_group_item_ops = {
	.release	= i40e_cfgfs_group_release,
	.show_attribute	= i40e_cfgfs_group_attr_show,
};

/* Note that, since no extra work is required on ->drop_item(),
 * no ->drop_item() is provided.
 */
static struct configfs_group_operations i40e_cfgfs_group_ops = {
	.make_item	= i40e_cfgfs_group_make_item,
};

static struct config_item_type i40e_cfgfs_group_type = {
	.ct_item_ops	= &i40e_cfgfs_group_item_ops,
	.ct_group_ops	= &i40e_cfgfs_group_ops,
	.ct_attrs	= i40e_cfgfs_group_attrs,
	.ct_owner	= THIS_MODULE,
};

static struct configfs_subsystem i40e_cfgfs_group_subsys = {
	.su_group = {
		.cg_item = {
			.ci_namebuf = "i40e",
			.ci_type = &i40e_cfgfs_group_type,
		},
	},
};

/**
 * i40e_configfs_init - Initialize configfs support for our driver
 **/
int i40e_configfs_init(void)
{
	int ret;
	struct configfs_subsystem *subsys;

	subsys = &i40e_cfgfs_group_subsys;

	config_group_init(&subsys->su_group);
	mutex_init(&subsys->su_mutex);
	ret = configfs_register_subsystem(subsys);
	if (ret) {
		pr_err("Error %d while registering configfs subsystem %s\n",
		       ret, subsys->su_group.cg_item.ci_namebuf);
		return ret;
	}

	return 0;
}

/**
 * i40e_configfs_init - Bail out - unregister configfs subsystem and release
 **/
void i40e_configfs_exit(void)
{
	configfs_unregister_subsystem(&i40e_cfgfs_group_subsys);
}
#endif /* IS_ENABLED(CONFIG_CONFIGFS_FS) */
+3 −2
Original line number Diff line number Diff line
@@ -921,9 +921,10 @@ static void i40e_dbg_dump_veb_seid(struct i40e_pf *pf, int seid)
		return;
	}
	dev_info(&pf->pdev->dev,
		 "veb idx=%d,%d stats_ic=%d  seid=%d uplink=%d\n",
		 "veb idx=%d,%d stats_ic=%d  seid=%d uplink=%d mode=%s\n",
		 veb->idx, veb->veb_idx, veb->stats_idx, veb->seid,
		 veb->uplink_seid);
		 veb->uplink_seid,
		 veb->bridge_mode == BRIDGE_MODE_VEPA ? "VEPA" : "VEB");
	i40e_dbg_dump_eth_stats(pf, &veb->stats);
}

Loading