Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH] net: ehea: fix wrongly-reported supported modes
From: Kleber Sacilotto de Souza @ 2011-05-04 21:59 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: netdev
In-Reply-To: <1304458460.2873.18.camel@bwh-desktop>

On Tue, 2011-05-03 at 22:34 +0100, Ben Hutchings wrote:
> On Tue, 2011-05-03 at 21:16 +0100, Ben Hutchings wrote:
> > On Tue, 2011-05-03 at 16:42 -0300, Kleber Sacilotto de Souza wrote:
> > > Currently EHEA reports to ethtool as supporting 10000baseT_Full and
> > > FIBRE independent of the hardware configuration. However, these
> > > capabilities should be reported only if the physical port and
> > > the medium support them, which is the case where the physical port
> > > is connected at 10Gb.
> > >
> > > Signed-off-by: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
> > > ---
> > >  drivers/net/ehea/ehea_ethtool.c |   21 ++++++++++++++-------
> > >  1 files changed, 14 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/drivers/net/ehea/ehea_ethtool.c b/drivers/net/ehea/ehea_ethtool.c
> > > index 3e2e734..04716c2 100644
> > > --- a/drivers/net/ehea/ehea_ethtool.c
> > > +++ b/drivers/net/ehea/ehea_ethtool.c
> > > @@ -55,15 +55,22 @@ static int ehea_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
> > >  		cmd->duplex = -1;
> > >  	}
> > > 
> > > -	cmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_1000baseT_Full
> > > -		       | SUPPORTED_100baseT_Full |  SUPPORTED_100baseT_Half
> > > -		       | SUPPORTED_10baseT_Full | SUPPORTED_10baseT_Half
> > > -		       | SUPPORTED_Autoneg | SUPPORTED_FIBRE);
> > > +	cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_100baseT_Full
> > > +		       | SUPPORTED_100baseT_Half | SUPPORTED_10baseT_Full
> > > +		       | SUPPORTED_10baseT_Half | SUPPORTED_Autoneg);
> > > 
> > > -	cmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_Autoneg
> > > -			 | ADVERTISED_FIBRE);
> > > +	cmd->advertising = ADVERTISED_Autoneg;
> > > +
> > > +	if (cmd->speed == SPEED_10000) {
> > > +		cmd->supported |= (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
> > > +		cmd->advertising |= (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE);
> > > +		cmd->port = PORT_FIBRE;
> > > +	} else {
> > > +		cmd->supported |= SUPPORTED_TP;
> > > +		cmd->advertising |= (ADVERTISED_1000baseT_Full | ADVERTISED_TP);
> > > +		cmd->port = PORT_TP;
> > > +	}
> > 
> > This doesn't make any sense.  If the current speed is 10G, then the
> > driver also claims to support speeds of 10M, 100M, 1G and 10G.  But then
>                                                                ^
>                                                            on fibre
> 
> > if the speed actually is <10G, the driver claims to support TP.  What's
> > going on here?

You are right. This patch was based on very vague hardware specs that
wasn't making much sense. I have more details about the hardware now, I
will send another patch soon.

> > 
> > (Also, claiming to support BASE-T modes on non-TP media is bogus, though
> > I understand why people are doing it.)
> > 
> > Ben.
> > 
> > > -	cmd->port = PORT_FIBRE;
> > >  	cmd->autoneg = port->autoneg == 1 ? AUTONEG_ENABLE : AUTONEG_DISABLE;
> > > 
> > >  	return 0;
> > 
> 

-- 
Kleber S. Souza
IBM Linux Technology Center


^ permalink raw reply

* Re: [PATCH 1/2] libertas: Convert lbs_pr_<level> to pr_<level>
From: Dan Williams @ 2011-05-04 22:15 UTC (permalink / raw)
  To: Joe Perches
  Cc: John W. Linville, libertas-dev, linux-wireless, netdev,
	linux-kernel
In-Reply-To: <353dfb1607172b5a3dbaccddbe52c24312d42af4.1304379925.git.joe@perches.com>

On Mon, 2011-05-02 at 16:49 -0700, Joe Perches wrote:
> Use the standard pr_<level> functions eases grep a bit.
> 
> Added a few missing terminating newlines to messages.
> Coalesced long formats.
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Acked-by: Dan Williams <dcbw@redhat.com>

> ---
>  drivers/net/wireless/libertas/cfg.c     |   15 +++---
>  drivers/net/wireless/libertas/cmd.c     |   36 +++++++-------
>  drivers/net/wireless/libertas/cmdresp.c |   29 +++++++-----
>  drivers/net/wireless/libertas/debugfs.c |    6 ++-
>  drivers/net/wireless/libertas/defs.h    |    7 ---
>  drivers/net/wireless/libertas/if_cs.c   |   52 +++++++++++----------
>  drivers/net/wireless/libertas/if_sdio.c |   38 ++++++++--------
>  drivers/net/wireless/libertas/if_spi.c  |   74 ++++++++++++++-----------------
>  drivers/net/wireless/libertas/if_usb.c  |   41 +++++++++--------
>  drivers/net/wireless/libertas/main.c    |   33 +++++++-------
>  drivers/net/wireless/libertas/mesh.c    |    8 ++-
>  drivers/net/wireless/libertas/rx.c      |    7 ++-
>  12 files changed, 174 insertions(+), 172 deletions(-)
> 
> diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c
> index 5caa2ac..d6e0656 100644
> --- a/drivers/net/wireless/libertas/cfg.c
> +++ b/drivers/net/wireless/libertas/cfg.c
> @@ -6,6 +6,8 @@
>   *
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/sched.h>
>  #include <linux/wait.h>
>  #include <linux/slab.h>
> @@ -1314,8 +1316,7 @@ static int lbs_cfg_connect(struct wiphy *wiphy, struct net_device *dev,
>  		sme->ssid, sme->ssid_len,
>  		WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
>  	if (!bss) {
> -		lbs_pr_err("assoc: bss %pM not in scan results\n",
> -			   sme->bssid);
> +		pr_err("assoc: bss %pM not in scan results\n", sme->bssid);
>  		ret = -ENOENT;
>  		goto done;
>  	}
> @@ -1372,8 +1373,8 @@ static int lbs_cfg_connect(struct wiphy *wiphy, struct net_device *dev,
>  		lbs_enable_rsn(priv, sme->crypto.cipher_group != 0);
>  		break;
>  	default:
> -		lbs_pr_err("unsupported cipher group 0x%x\n",
> -			   sme->crypto.cipher_group);
> +		pr_err("unsupported cipher group 0x%x\n",
> +		       sme->crypto.cipher_group);
>  		ret = -ENOTSUPP;
>  		goto done;
>  	}
> @@ -1491,7 +1492,7 @@ static int lbs_cfg_add_key(struct wiphy *wiphy, struct net_device *netdev,
>  				     params->key, params->key_len);
>  		break;
>  	default:
> -		lbs_pr_err("unhandled cipher 0x%x\n", params->cipher);
> +		pr_err("unhandled cipher 0x%x\n", params->cipher);
>  		ret = -ENOTSUPP;
>  		break;
>  	}
> @@ -2118,13 +2119,13 @@ int lbs_cfg_register(struct lbs_private *priv)
>  
>  	ret = wiphy_register(wdev->wiphy);
>  	if (ret < 0)
> -		lbs_pr_err("cannot register wiphy device\n");
> +		pr_err("cannot register wiphy device\n");
>  
>  	priv->wiphy_registered = true;
>  
>  	ret = register_netdev(priv->dev);
>  	if (ret)
> -		lbs_pr_err("cannot register network device\n");
> +		pr_err("cannot register network device\n");
>  
>  	INIT_DELAYED_WORK(&priv->scan_work, lbs_scan_worker);
>  
> diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
> index 7e8a658..10ca485 100644
> --- a/drivers/net/wireless/libertas/cmd.c
> +++ b/drivers/net/wireless/libertas/cmd.c
> @@ -3,6 +3,8 @@
>    * It prepares command and sends it to firmware when it is ready.
>    */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/kfifo.h>
>  #include <linux/sched.h>
>  #include <linux/slab.h>
> @@ -108,7 +110,7 @@ int lbs_update_hw_spec(struct lbs_private *priv)
>  	 * CF card    firmware 5.0.16p0:   cap 0x00000303
>  	 * USB dongle firmware 5.110.17p2: cap 0x00000303
>  	 */
> -	lbs_pr_info("%pM, fw %u.%u.%up%u, cap 0x%08x\n",
> +	pr_info("%pM, fw %u.%u.%up%u, cap 0x%08x\n",
>  		cmd.permanentaddr,
>  		priv->fwrelease >> 24 & 0xff,
>  		priv->fwrelease >> 16 & 0xff,
> @@ -139,7 +141,7 @@ int lbs_update_hw_spec(struct lbs_private *priv)
>  	/* if it's unidentified region code, use the default (USA) */
>  	if (i >= MRVDRV_MAX_REGION_CODE) {
>  		priv->regioncode = 0x10;
> -		lbs_pr_info("unidentified region code; using the default (USA)\n");
> +		pr_info("unidentified region code; using the default (USA)\n");
>  	}
>  
>  	if (priv->current_addr[0] == 0xff)
> @@ -209,7 +211,7 @@ int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria,
>  					(uint8_t *)&cmd_config.wol_conf,
>  					sizeof(struct wol_config));
>  	} else {
> -		lbs_pr_info("HOST_SLEEP_CFG failed %d\n", ret);
> +		pr_info("HOST_SLEEP_CFG failed %d\n", ret);
>  	}
>  
>  	return ret;
> @@ -312,7 +314,7 @@ static int lbs_wait_for_ds_awake(struct lbs_private *priv)
>  	if (priv->is_deep_sleep) {
>  		if (!wait_event_interruptible_timeout(priv->ds_awake_q,
>  					!priv->is_deep_sleep, (10 * HZ))) {
> -			lbs_pr_err("ds_awake_q: timer expired\n");
> +			pr_err("ds_awake_q: timer expired\n");
>  			ret = -1;
>  		}
>  	}
> @@ -337,7 +339,7 @@ int lbs_set_deep_sleep(struct lbs_private *priv, int deep_sleep)
>  				netif_carrier_off(priv->dev);
>  			}
>  		} else {
> -			lbs_pr_err("deep sleep: already enabled\n");
> +			pr_err("deep sleep: already enabled\n");
>  		}
>  	} else {
>  		if (priv->is_deep_sleep) {
> @@ -347,8 +349,7 @@ int lbs_set_deep_sleep(struct lbs_private *priv, int deep_sleep)
>  			if (!ret) {
>  				ret = lbs_wait_for_ds_awake(priv);
>  				if (ret)
> -					lbs_pr_err("deep sleep: wakeup"
> -							"failed\n");
> +					pr_err("deep sleep: wakeup failed\n");
>  			}
>  		}
>  	}
> @@ -382,8 +383,8 @@ int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep)
>  			ret = lbs_host_sleep_cfg(priv, priv->wol_criteria,
>  					(struct wol_config *)NULL);
>  			if (ret) {
> -				lbs_pr_info("Host sleep configuration failed: "
> -						"%d\n", ret);
> +				pr_info("Host sleep configuration failed: %d\n",
> +					ret);
>  				return ret;
>  			}
>  			if (priv->psstate == PS_STATE_FULL_POWER) {
> @@ -393,19 +394,19 @@ int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep)
>  						sizeof(cmd),
>  						lbs_ret_host_sleep_activate, 0);
>  				if (ret)
> -					lbs_pr_info("HOST_SLEEP_ACTIVATE "
> -							"failed: %d\n", ret);
> +					pr_info("HOST_SLEEP_ACTIVATE failed: %d\n",
> +						ret);
>  			}
>  
>  			if (!wait_event_interruptible_timeout(
>  						priv->host_sleep_q,
>  						priv->is_host_sleep_activated,
>  						(10 * HZ))) {
> -				lbs_pr_err("host_sleep_q: timer expired\n");
> +				pr_err("host_sleep_q: timer expired\n");
>  				ret = -1;
>  			}
>  		} else {
> -			lbs_pr_err("host sleep: already enabled\n");
> +			pr_err("host sleep: already enabled\n");
>  		}
>  	} else {
>  		if (priv->is_host_sleep_activated)
> @@ -1002,7 +1003,7 @@ static void lbs_submit_command(struct lbs_private *priv,
>  	ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize);
>  
>  	if (ret) {
> -		lbs_pr_info("DNLD_CMD: hw_host_to_card failed: %d\n", ret);
> +		pr_info("DNLD_CMD: hw_host_to_card failed: %d\n", ret);
>  		/* Let the timer kick in and retry, and potentially reset
>  		   the whole thing if the condition persists */
>  		timeo = HZ/4;
> @@ -1267,7 +1268,7 @@ int lbs_execute_next_command(struct lbs_private *priv)
>  	spin_lock_irqsave(&priv->driver_lock, flags);
>  
>  	if (priv->cur_cmd) {
> -		lbs_pr_alert( "EXEC_NEXT_CMD: already processing command!\n");
> +		pr_alert( "EXEC_NEXT_CMD: already processing command!\n");
>  		spin_unlock_irqrestore(&priv->driver_lock, flags);
>  		ret = -1;
>  		goto done;
> @@ -1429,7 +1430,7 @@ static void lbs_send_confirmsleep(struct lbs_private *priv)
>  	ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) &confirm_sleep,
>  		sizeof(confirm_sleep));
>  	if (ret) {
> -		lbs_pr_alert("confirm_sleep failed\n");
> +		pr_alert("confirm_sleep failed\n");
>  		goto out;
>  	}
>  
> @@ -1655,8 +1656,7 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command,
>  	spin_lock_irqsave(&priv->driver_lock, flags);
>  	ret = cmdnode->result;
>  	if (ret)
> -		lbs_pr_info("PREP_CMD: command 0x%04x failed: %d\n",
> -			    command, ret);
> +		pr_info("PREP_CMD: command 0x%04x failed: %d\n", command, ret);
>  
>  	__lbs_cleanup_and_insert_cmd(priv, cmdnode);
>  	spin_unlock_irqrestore(&priv->driver_lock, flags);
> diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
> index 5e95da9..2cb6f5f 100644
> --- a/drivers/net/wireless/libertas/cmdresp.c
> +++ b/drivers/net/wireless/libertas/cmdresp.c
> @@ -2,6 +2,9 @@
>    * This file contains the handling of command
>    * responses as well as events generated by firmware.
>    */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/slab.h>
>  #include <linux/delay.h>
>  #include <linux/sched.h>
> @@ -84,15 +87,17 @@ int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len)
>  	lbs_deb_hex(LBS_DEB_CMD, "CMD_RESP", (void *) resp, len);
>  
>  	if (resp->seqnum != priv->cur_cmd->cmdbuf->seqnum) {
> -		lbs_pr_info("Received CMD_RESP with invalid sequence %d (expected %d)\n",
> -			    le16_to_cpu(resp->seqnum), le16_to_cpu(priv->cur_cmd->cmdbuf->seqnum));
> +		pr_info("Received CMD_RESP with invalid sequence %d (expected %d)\n",
> +			le16_to_cpu(resp->seqnum),
> +			le16_to_cpu(priv->cur_cmd->cmdbuf->seqnum));
>  		spin_unlock_irqrestore(&priv->driver_lock, flags);
>  		ret = -1;
>  		goto done;
>  	}
>  	if (respcmd != CMD_RET(curcmd) &&
>  	    respcmd != CMD_RET_802_11_ASSOCIATE && curcmd != CMD_802_11_ASSOCIATE) {
> -		lbs_pr_info("Invalid CMD_RESP %x to command %x!\n", respcmd, curcmd);
> +		pr_info("Invalid CMD_RESP %x to command %x!\n",
> +			respcmd, curcmd);
>  		spin_unlock_irqrestore(&priv->driver_lock, flags);
>  		ret = -1;
>  		goto done;
> @@ -101,8 +106,8 @@ int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len)
>  	if (resp->result == cpu_to_le16(0x0004)) {
>  		/* 0x0004 means -EAGAIN. Drop the response, let it time out
>  		   and be resubmitted */
> -		lbs_pr_info("Firmware returns DEFER to command %x. Will let it time out...\n",
> -			    le16_to_cpu(resp->command));
> +		pr_info("Firmware returns DEFER to command %x. Will let it time out...\n",
> +			le16_to_cpu(resp->command));
>  		spin_unlock_irqrestore(&priv->driver_lock, flags);
>  		ret = -1;
>  		goto done;
> @@ -313,28 +318,28 @@ int lbs_process_event(struct lbs_private *priv, u32 event)
>  		lbs_deb_cmd("EVENT: ADHOC beacon lost\n");
>  		break;
>  	case MACREG_INT_CODE_RSSI_LOW:
> -		lbs_pr_alert("EVENT: rssi low\n");
> +		pr_alert("EVENT: rssi low\n");
>  		break;
>  	case MACREG_INT_CODE_SNR_LOW:
> -		lbs_pr_alert("EVENT: snr low\n");
> +		pr_alert("EVENT: snr low\n");
>  		break;
>  	case MACREG_INT_CODE_MAX_FAIL:
> -		lbs_pr_alert("EVENT: max fail\n");
> +		pr_alert("EVENT: max fail\n");
>  		break;
>  	case MACREG_INT_CODE_RSSI_HIGH:
> -		lbs_pr_alert("EVENT: rssi high\n");
> +		pr_alert("EVENT: rssi high\n");
>  		break;
>  	case MACREG_INT_CODE_SNR_HIGH:
> -		lbs_pr_alert("EVENT: snr high\n");
> +		pr_alert("EVENT: snr high\n");
>  		break;
>  
>  	case MACREG_INT_CODE_MESH_AUTO_STARTED:
>  		/* Ignore spurious autostart events */
> -		lbs_pr_info("EVENT: MESH_AUTO_STARTED (ignoring)\n");
> +		pr_info("EVENT: MESH_AUTO_STARTED (ignoring)\n");
>  		break;
>  
>  	default:
> -		lbs_pr_alert("EVENT: unknown event id %d\n", event);
> +		pr_alert("EVENT: unknown event id %d\n", event);
>  		break;
>  	}
>  
> diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
> index fbf3b033..c179094 100644
> --- a/drivers/net/wireless/libertas/debugfs.c
> +++ b/drivers/net/wireless/libertas/debugfs.c
> @@ -1,3 +1,5 @@
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/dcache.h>
>  #include <linux/debugfs.h>
>  #include <linux/delay.h>
> @@ -151,13 +153,13 @@ static ssize_t lbs_host_sleep_write(struct file *file,
>  		ret = lbs_set_host_sleep(priv, 0);
>  	else if (host_sleep == 1) {
>  		if (priv->wol_criteria == EHS_REMOVE_WAKEUP) {
> -			lbs_pr_info("wake parameters not configured");
> +			pr_info("wake parameters not configured\n");
>  			ret = -EINVAL;
>  			goto out_unlock;
>  		}
>  		ret = lbs_set_host_sleep(priv, 1);
>  	} else {
> -		lbs_pr_err("invalid option\n");
> +		pr_err("invalid option\n");
>  		ret = -EINVAL;
>  	}
>  
> diff --git a/drivers/net/wireless/libertas/defs.h b/drivers/net/wireless/libertas/defs.h
> index d00c728..c9b89b0 100644
> --- a/drivers/net/wireless/libertas/defs.h
> +++ b/drivers/net/wireless/libertas/defs.h
> @@ -89,13 +89,6 @@ do { if ((lbs_debug & (grp)) == (grp)) \
>  #define lbs_deb_spi(fmt, args...)       LBS_DEB_LL(LBS_DEB_SPI, " spi", fmt, ##args)
>  #define lbs_deb_cfg80211(fmt, args...)  LBS_DEB_LL(LBS_DEB_CFG80211, " cfg80211", fmt, ##args)
>  
> -#define lbs_pr_info(format, args...) \
> -	printk(KERN_INFO DRV_NAME": " format, ## args)
> -#define lbs_pr_err(format, args...) \
> -	printk(KERN_ERR DRV_NAME": " format, ## args)
> -#define lbs_pr_alert(format, args...) \
> -	printk(KERN_ALERT DRV_NAME": " format, ## args)
> -
>  #ifdef DEBUG
>  static inline void lbs_deb_hex(unsigned int grp, const char *prompt, u8 *buf, int len)
>  {
> diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
> index 8712cb2..eb88d9a 100644
> --- a/drivers/net/wireless/libertas/if_cs.c
> +++ b/drivers/net/wireless/libertas/if_cs.c
> @@ -21,6 +21,8 @@
>  
>  */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/module.h>
>  #include <linux/slab.h>
>  #include <linux/delay.h>
> @@ -361,7 +363,7 @@ static int if_cs_send_cmd(struct lbs_private *priv, u8 *buf, u16 nb)
>  		if (status & IF_CS_BIT_COMMAND)
>  			break;
>  		if (++loops > 100) {
> -			lbs_pr_err("card not ready for commands\n");
> +			pr_err("card not ready for commands\n");
>  			goto done;
>  		}
>  		mdelay(1);
> @@ -431,14 +433,14 @@ static int if_cs_receive_cmdres(struct lbs_private *priv, u8 *data, u32 *len)
>  	/* is hardware ready? */
>  	status = if_cs_read16(priv->card, IF_CS_CARD_STATUS);
>  	if ((status & IF_CS_BIT_RESP) == 0) {
> -		lbs_pr_err("no cmd response in card\n");
> +		pr_err("no cmd response in card\n");
>  		*len = 0;
>  		goto out;
>  	}
>  
>  	*len = if_cs_read16(priv->card, IF_CS_RESP_LEN);
>  	if ((*len == 0) || (*len > LBS_CMD_BUFFER_SIZE)) {
> -		lbs_pr_err("card cmd buffer has invalid # of bytes (%d)\n", *len);
> +		pr_err("card cmd buffer has invalid # of bytes (%d)\n", *len);
>  		goto out;
>  	}
>  
> @@ -472,7 +474,7 @@ static struct sk_buff *if_cs_receive_data(struct lbs_private *priv)
>  
>  	len = if_cs_read16(priv->card, IF_CS_READ_LEN);
>  	if (len == 0 || len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) {
> -		lbs_pr_err("card data buffer has invalid # of bytes (%d)\n", len);
> +		pr_err("card data buffer has invalid # of bytes (%d)\n", len);
>  		priv->dev->stats.rx_dropped++;
>  		goto dat_err;
>  	}
> @@ -644,8 +646,8 @@ static int if_cs_prog_helper(struct if_cs_card *card, const struct firmware *fw)
>  		ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_STATUS,
>  			IF_CS_BIT_COMMAND);
>  		if (ret < 0) {
> -			lbs_pr_err("can't download helper at 0x%x, ret %d\n",
> -				sent, ret);
> +			pr_err("can't download helper at 0x%x, ret %d\n",
> +			       sent, ret);
>  			goto done;
>  		}
>  
> @@ -675,7 +677,7 @@ static int if_cs_prog_real(struct if_cs_card *card, const struct firmware *fw)
>  	ret = if_cs_poll_while_fw_download(card, IF_CS_SQ_READ_LOW,
>  		IF_CS_SQ_HELPER_OK);
>  	if (ret < 0) {
> -		lbs_pr_err("helper firmware doesn't answer\n");
> +		pr_err("helper firmware doesn't answer\n");
>  		goto done;
>  	}
>  
> @@ -683,13 +685,13 @@ static int if_cs_prog_real(struct if_cs_card *card, const struct firmware *fw)
>  		len = if_cs_read16(card, IF_CS_SQ_READ_LOW);
>  		if (len & 1) {
>  			retry++;
> -			lbs_pr_info("odd, need to retry this firmware block\n");
> +			pr_info("odd, need to retry this firmware block\n");
>  		} else {
>  			retry = 0;
>  		}
>  
>  		if (retry > 20) {
> -			lbs_pr_err("could not download firmware\n");
> +			pr_err("could not download firmware\n");
>  			ret = -ENODEV;
>  			goto done;
>  		}
> @@ -709,14 +711,14 @@ static int if_cs_prog_real(struct if_cs_card *card, const struct firmware *fw)
>  		ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_STATUS,
>  			IF_CS_BIT_COMMAND);
>  		if (ret < 0) {
> -			lbs_pr_err("can't download firmware at 0x%x\n", sent);
> +			pr_err("can't download firmware at 0x%x\n", sent);
>  			goto done;
>  		}
>  	}
>  
>  	ret = if_cs_poll_while_fw_download(card, IF_CS_SCRATCH, 0x5a);
>  	if (ret < 0)
> -		lbs_pr_err("firmware download failed\n");
> +		pr_err("firmware download failed\n");
>  
>  done:
>  	lbs_deb_leave_args(LBS_DEB_CS, "ret %d", ret);
> @@ -750,7 +752,7 @@ static int if_cs_host_to_card(struct lbs_private *priv,
>  		ret = if_cs_send_cmd(priv, buf, nb);
>  		break;
>  	default:
> -		lbs_pr_err("%s: unsupported type %d\n", __func__, type);
> +		pr_err("%s: unsupported type %d\n", __func__, type);
>  	}
>  
>  	lbs_deb_leave_args(LBS_DEB_CS, "ret %d", ret);
> @@ -779,7 +781,7 @@ static int if_cs_ioprobe(struct pcmcia_device *p_dev, void *priv_data)
>  	p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
>  
>  	if (p_dev->resource[1]->end) {
> -		lbs_pr_err("wrong CIS (check number of IO windows)\n");
> +		pr_err("wrong CIS (check number of IO windows)\n");
>  		return -ENODEV;
>  	}
>  
> @@ -800,7 +802,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
>  
>  	card = kzalloc(sizeof(struct if_cs_card), GFP_KERNEL);
>  	if (!card) {
> -		lbs_pr_err("error in kzalloc\n");
> +		pr_err("error in kzalloc\n");
>  		goto out;
>  	}
>  	card->p_dev = p_dev;
> @@ -809,7 +811,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
>  	p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
>  
>  	if (pcmcia_loop_config(p_dev, if_cs_ioprobe, NULL)) {
> -		lbs_pr_err("error in pcmcia_loop_config\n");
> +		pr_err("error in pcmcia_loop_config\n");
>  		goto out1;
>  	}
>  
> @@ -825,14 +827,14 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
>  	card->iobase = ioport_map(p_dev->resource[0]->start,
>  				resource_size(p_dev->resource[0]));
>  	if (!card->iobase) {
> -		lbs_pr_err("error in ioport_map\n");
> +		pr_err("error in ioport_map\n");
>  		ret = -EIO;
>  		goto out1;
>  	}
>  
>  	ret = pcmcia_enable_device(p_dev);
>  	if (ret) {
> -		lbs_pr_err("error in pcmcia_enable_device\n");
> +		pr_err("error in pcmcia_enable_device\n");
>  		goto out2;
>  	}
>  
> @@ -847,8 +849,8 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
>  
>  	card->model = get_model(p_dev->manf_id, p_dev->card_id);
>  	if (card->model == MODEL_UNKNOWN) {
> -		lbs_pr_err("unsupported manf_id 0x%04x / card_id 0x%04x\n",
> -			   p_dev->manf_id, p_dev->card_id);
> +		pr_err("unsupported manf_id 0x%04x / card_id 0x%04x\n",
> +		       p_dev->manf_id, p_dev->card_id);
>  		goto out2;
>  	}
>  
> @@ -857,20 +859,20 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
>  	if (card->model == MODEL_8305) {
>  		card->align_regs = 1;
>  		if (prod_id < IF_CS_CF8305_B1_REV) {
> -			lbs_pr_err("8305 rev B0 and older are not supported\n");
> +			pr_err("8305 rev B0 and older are not supported\n");
>  			ret = -ENODEV;
>  			goto out2;
>  		}
>  	}
>  
>  	if ((card->model == MODEL_8381) && prod_id < IF_CS_CF8381_B3_REV) {
> -		lbs_pr_err("8381 rev B2 and older are not supported\n");
> +		pr_err("8381 rev B2 and older are not supported\n");
>  		ret = -ENODEV;
>  		goto out2;
>  	}
>  
>  	if ((card->model == MODEL_8385) && prod_id < IF_CS_CF8385_B1_REV) {
> -		lbs_pr_err("8385 rev B0 and older are not supported\n");
> +		pr_err("8385 rev B0 and older are not supported\n");
>  		ret = -ENODEV;
>  		goto out2;
>  	}
> @@ -878,7 +880,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
>  	ret = lbs_get_firmware(&p_dev->dev, NULL, NULL, card->model,
>  				&fw_table[0], &helper, &mainfw);
>  	if (ret) {
> -		lbs_pr_err("failed to find firmware (%d)\n", ret);
> +		pr_err("failed to find firmware (%d)\n", ret);
>  		goto out2;
>  	}
>  
> @@ -909,7 +911,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
>  	ret = request_irq(p_dev->irq, if_cs_interrupt,
>  		IRQF_SHARED, DRV_NAME, card);
>  	if (ret) {
> -		lbs_pr_err("error in request_irq\n");
> +		pr_err("error in request_irq\n");
>  		goto out3;
>  	}
>  
> @@ -920,7 +922,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
>  
>  	/* And finally bring the card up */
>  	if (lbs_start_card(priv) != 0) {
> -		lbs_pr_err("could not activate card\n");
> +		pr_err("could not activate card\n");
>  		goto out3;
>  	}
>  
> diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
> index b4de0ca..ab86779 100644
> --- a/drivers/net/wireless/libertas/if_sdio.c
> +++ b/drivers/net/wireless/libertas/if_sdio.c
> @@ -26,6 +26,8 @@
>   * if_sdio_card_to_host() to pad the data.
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/kernel.h>
>  #include <linux/moduleparam.h>
>  #include <linux/slab.h>
> @@ -409,7 +411,7 @@ static int if_sdio_card_to_host(struct if_sdio_card *card)
>  
>  out:
>  	if (ret)
> -		lbs_pr_err("problem fetching packet from firmware\n");
> +		pr_err("problem fetching packet from firmware\n");
>  
>  	lbs_deb_leave_args(LBS_DEB_SDIO, "ret %d", ret);
>  
> @@ -446,7 +448,7 @@ static void if_sdio_host_to_card_worker(struct work_struct *work)
>  		}
>  
>  		if (ret)
> -			lbs_pr_err("error %d sending packet to firmware\n", ret);
> +			pr_err("error %d sending packet to firmware\n", ret);
>  
>  		sdio_release_host(card->func);
>  
> @@ -555,7 +557,7 @@ release:
>  
>  out:
>  	if (ret)
> -		lbs_pr_err("failed to load helper firmware\n");
> +		pr_err("failed to load helper firmware\n");
>  
>  	lbs_deb_leave_args(LBS_DEB_SDIO, "ret %d", ret);
>  	return ret;
> @@ -669,7 +671,7 @@ release:
>  
>  out:
>  	if (ret)
> -		lbs_pr_err("failed to load firmware\n");
> +		pr_err("failed to load firmware\n");
>  
>  	lbs_deb_leave_args(LBS_DEB_SDIO, "ret %d", ret);
>  	return ret;
> @@ -723,7 +725,7 @@ static int if_sdio_prog_firmware(struct if_sdio_card *card)
>  	ret = lbs_get_firmware(&card->func->dev, lbs_helper_name, lbs_fw_name,
>  				card->model, &fw_table[0], &helper, &mainfw);
>  	if (ret) {
> -		lbs_pr_err("failed to find firmware (%d)\n", ret);
> +		pr_err("failed to find firmware (%d)\n", ret);
>  		goto out;
>  	}
>  
> @@ -849,7 +851,7 @@ static int if_sdio_enter_deep_sleep(struct lbs_private *priv)
>  	ret = __lbs_cmd(priv, CMD_802_11_DEEP_SLEEP, &cmd, sizeof(cmd),
>  			lbs_cmd_copyback, (unsigned long) &cmd);
>  	if (ret)
> -		lbs_pr_err("DEEP_SLEEP cmd failed\n");
> +		pr_err("DEEP_SLEEP cmd failed\n");
>  
>  	mdelay(200);
>  	return ret;
> @@ -865,7 +867,7 @@ static int if_sdio_exit_deep_sleep(struct lbs_private *priv)
>  
>  	sdio_writeb(card->func, HOST_POWER_UP, CONFIGURATION_REG, &ret);
>  	if (ret)
> -		lbs_pr_err("sdio_writeb failed!\n");
> +		pr_err("sdio_writeb failed!\n");
>  
>  	sdio_release_host(card->func);
>  	lbs_deb_leave_args(LBS_DEB_SDIO, "ret %d", ret);
> @@ -882,7 +884,7 @@ static int if_sdio_reset_deep_sleep_wakeup(struct lbs_private *priv)
>  
>  	sdio_writeb(card->func, 0, CONFIGURATION_REG, &ret);
>  	if (ret)
> -		lbs_pr_err("sdio_writeb failed!\n");
> +		pr_err("sdio_writeb failed!\n");
>  
>  	sdio_release_host(card->func);
>  	lbs_deb_leave_args(LBS_DEB_SDIO, "ret %d", ret);
> @@ -961,7 +963,7 @@ static int if_sdio_probe(struct sdio_func *func,
>  	}
>  
>  	if (i == func->card->num_info) {
> -		lbs_pr_err("unable to identify card model\n");
> +		pr_err("unable to identify card model\n");
>  		return -ENODEV;
>  	}
>  
> @@ -995,7 +997,7 @@ static int if_sdio_probe(struct sdio_func *func,
>  			break;
>  	}
>  	if (i == ARRAY_SIZE(fw_table)) {
> -		lbs_pr_err("unknown card model 0x%x\n", card->model);
> +		pr_err("unknown card model 0x%x\n", card->model);
>  		ret = -ENODEV;
>  		goto free;
>  	}
> @@ -1101,7 +1103,7 @@ static int if_sdio_probe(struct sdio_func *func,
>  		lbs_deb_sdio("send function INIT command\n");
>  		if (__lbs_cmd(priv, CMD_FUNC_INIT, &cmd, sizeof(cmd),
>  				lbs_cmd_copyback, (unsigned long) &cmd))
> -			lbs_pr_alert("CMD_FUNC_INIT cmd failed\n");
> +			pr_alert("CMD_FUNC_INIT cmd failed\n");
>  	}
>  
>  	ret = lbs_start_card(priv);
> @@ -1163,7 +1165,7 @@ static void if_sdio_remove(struct sdio_func *func)
>  		if (__lbs_cmd(card->priv, CMD_FUNC_SHUTDOWN,
>  				&cmd, sizeof(cmd), lbs_cmd_copyback,
>  				(unsigned long) &cmd))
> -			lbs_pr_alert("CMD_FUNC_SHUTDOWN cmd failed\n");
> +			pr_alert("CMD_FUNC_SHUTDOWN cmd failed\n");
>  	}
>  
> 
> @@ -1202,21 +1204,19 @@ static int if_sdio_suspend(struct device *dev)
>  
>  	mmc_pm_flag_t flags = sdio_get_host_pm_caps(func);
>  
> -	lbs_pr_info("%s: suspend: PM flags = 0x%x\n",
> -						sdio_func_id(func), flags);
> +	pr_info("%s: suspend: PM flags = 0x%x\n", sdio_func_id(func), flags);
>  
>  	/* If we aren't being asked to wake on anything, we should bail out
>  	 * and let the SD stack power down the card.
>  	 */
>  	if (card->priv->wol_criteria == EHS_REMOVE_WAKEUP) {
> -		lbs_pr_info("Suspend without wake params -- "
> -						"powering down card.");
> +		pr_info("Suspend without wake params -- powering down card\n");
>  		return -ENOSYS;
>  	}
>  
>  	if (!(flags & MMC_PM_KEEP_POWER)) {
> -		lbs_pr_err("%s: cannot remain alive while host is suspended\n",
> -			sdio_func_id(func));
> +		pr_err("%s: cannot remain alive while host is suspended\n",
> +		       sdio_func_id(func));
>  		return -ENOSYS;
>  	}
>  
> @@ -1237,7 +1237,7 @@ static int if_sdio_resume(struct device *dev)
>  	struct if_sdio_card *card = sdio_get_drvdata(func);
>  	int ret;
>  
> -	lbs_pr_info("%s: resume: we're back\n", sdio_func_id(func));
> +	pr_info("%s: resume: we're back\n", sdio_func_id(func));
>  
>  	ret = lbs_resume(card->priv);
>  
> diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c
> index 078ef43..bebd9f0 100644
> --- a/drivers/net/wireless/libertas/if_spi.c
> +++ b/drivers/net/wireless/libertas/if_spi.c
> @@ -17,6 +17,8 @@
>   * (at your option) any later version.
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/moduleparam.h>
>  #include <linux/firmware.h>
>  #include <linux/jiffies.h>
> @@ -297,8 +299,7 @@ static int spu_wait_for_u16(struct if_spi_card *card, u16 reg,
>  		}
>  		udelay(100);
>  		if (time_after(jiffies, timeout)) {
> -			lbs_pr_err("%s: timeout with val=%02x, "
> -			       "target_mask=%02x, target=%02x\n",
> +			pr_err("%s: timeout with val=%02x, target_mask=%02x, target=%02x\n",
>  			       __func__, val, target_mask, target);
>  			return -ETIMEDOUT;
>  		}
> @@ -391,7 +392,7 @@ static int spu_set_bus_mode(struct if_spi_card *card, u16 mode)
>  	if (err)
>  		return err;
>  	if ((rval & 0xF) != mode) {
> -		lbs_pr_err("Can't read bus mode register.\n");
> +		pr_err("Can't read bus mode register\n");
>  		return -EIO;
>  	}
>  	return 0;
> @@ -512,7 +513,7 @@ static int if_spi_prog_helper_firmware(struct if_spi_card *card,
>  
>  out:
>  	if (err)
> -		lbs_pr_err("failed to load helper firmware (err=%d)\n", err);
> +		pr_err("failed to load helper firmware (err=%d)\n", err);
>  	lbs_deb_leave_args(LBS_DEB_SPI, "err %d", err);
>  	return err;
>  }
> @@ -531,7 +532,7 @@ static int if_spi_prog_main_firmware_check_len(struct if_spi_card *card,
>  				IF_SPI_HIST_CMD_DOWNLOAD_RDY,
>  				IF_SPI_HIST_CMD_DOWNLOAD_RDY);
>  	if (err) {
> -		lbs_pr_err("timed out waiting for host_int_status\n");
> +		pr_err("timed out waiting for host_int_status\n");
>  		return err;
>  	}
>  
> @@ -541,9 +542,8 @@ static int if_spi_prog_main_firmware_check_len(struct if_spi_card *card,
>  		return err;
>  
>  	if (len > IF_SPI_CMD_BUF_SIZE) {
> -		lbs_pr_err("firmware load device requested a larger "
> -			   "tranfer than we are prepared to "
> -			   "handle. (len = %d)\n", len);
> +		pr_err("firmware load device requested a larger transfer than we are prepared to handle (len = %d)\n",
> +		       len);
>  		return -EIO;
>  	}
>  	if (len & 0x1) {
> @@ -572,8 +572,8 @@ static int if_spi_prog_main_firmware(struct if_spi_card *card,
>  
>  	err = spu_wait_for_u16(card, IF_SPI_SCRATCH_1_REG, 0, 0);
>  	if (err) {
> -		lbs_pr_err("%s: timed out waiting for initial "
> -			   "scratch reg = 0\n", __func__);
> +		pr_err("%s: timed out waiting for initial scratch reg = 0\n",
> +		       __func__);
>  		goto out;
>  	}
>  
> @@ -589,15 +589,13 @@ static int if_spi_prog_main_firmware(struct if_spi_card *card,
>  		if (bytes < 0) {
>  			/* If there are no more bytes left, we would normally
>  			 * expect to have terminated with len = 0 */
> -			lbs_pr_err("Firmware load wants more bytes "
> -				   "than we have to offer.\n");
> +			pr_err("Firmware load wants more bytes than we have to offer\n");
>  			break;
>  		}
>  		if (crc_err) {
>  			/* Previous transfer failed. */
>  			if (++num_crc_errs > MAX_MAIN_FW_LOAD_CRC_ERR) {
> -				lbs_pr_err("Too many CRC errors encountered "
> -					   "in firmware load.\n");
> +				pr_err("Too many CRC errors encountered in firmware load\n");
>  				err = -EIO;
>  				goto out;
>  			}
> @@ -626,21 +624,20 @@ static int if_spi_prog_main_firmware(struct if_spi_card *card,
>  		prev_len = len;
>  	}
>  	if (bytes > prev_len) {
> -		lbs_pr_err("firmware load wants fewer bytes than "
> -			   "we have to offer.\n");
> +		pr_err("firmware load wants fewer bytes than we have to offer\n");
>  	}
>  
>  	/* Confirm firmware download */
>  	err = spu_wait_for_u32(card, IF_SPI_SCRATCH_4_REG,
>  					SUCCESSFUL_FW_DOWNLOAD_MAGIC);
>  	if (err) {
> -		lbs_pr_err("failed to confirm the firmware download\n");
> +		pr_err("failed to confirm the firmware download\n");
>  		goto out;
>  	}
>  
>  out:
>  	if (err)
> -		lbs_pr_err("failed to load firmware (err=%d)\n", err);
> +		pr_err("failed to load firmware (err=%d)\n", err);
>  	lbs_deb_leave_args(LBS_DEB_SPI, "err %d", err);
>  	return err;
>  }
> @@ -677,14 +674,12 @@ static int if_spi_c2h_cmd(struct if_spi_card *card)
>  	if (err)
>  		goto out;
>  	if (!len) {
> -		lbs_pr_err("%s: error: card has no data for host\n",
> -			   __func__);
> +		pr_err("%s: error: card has no data for host\n", __func__);
>  		err = -EINVAL;
>  		goto out;
>  	} else if (len > IF_SPI_CMD_BUF_SIZE) {
> -		lbs_pr_err("%s: error: response packet too large: "
> -			   "%d bytes, but maximum is %d\n",
> -			   __func__, len, IF_SPI_CMD_BUF_SIZE);
> +		pr_err("%s: error: response packet too large: %d bytes, but maximum is %d\n",
> +		       __func__, len, IF_SPI_CMD_BUF_SIZE);
>  		err = -EINVAL;
>  		goto out;
>  	}
> @@ -705,7 +700,7 @@ static int if_spi_c2h_cmd(struct if_spi_card *card)
>  
>  out:
>  	if (err)
> -		lbs_pr_err("%s: err=%d\n", __func__, err);
> +		pr_err("%s: err=%d\n", __func__, err);
>  	lbs_deb_leave(LBS_DEB_SPI);
>  	return err;
>  }
> @@ -725,14 +720,12 @@ static int if_spi_c2h_data(struct if_spi_card *card)
>  	if (err)
>  		goto out;
>  	if (!len) {
> -		lbs_pr_err("%s: error: card has no data for host\n",
> -			   __func__);
> +		pr_err("%s: error: card has no data for host\n", __func__);
>  		err = -EINVAL;
>  		goto out;
>  	} else if (len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) {
> -		lbs_pr_err("%s: error: card has %d bytes of data, but "
> -			   "our maximum skb size is %zu\n",
> -			   __func__, len, MRVDRV_ETH_RX_PACKET_BUFFER_SIZE);
> +		pr_err("%s: error: card has %d bytes of data, but our maximum skb size is %zu\n",
> +		       __func__, len, MRVDRV_ETH_RX_PACKET_BUFFER_SIZE);
>  		err = -EINVAL;
>  		goto out;
>  	}
> @@ -763,7 +756,7 @@ free_skb:
>  	dev_kfree_skb(skb);
>  out:
>  	if (err)
> -		lbs_pr_err("%s: err=%d\n", __func__, err);
> +		pr_err("%s: err=%d\n", __func__, err);
>  	lbs_deb_leave(LBS_DEB_SPI);
>  	return err;
>  }
> @@ -785,7 +778,7 @@ static void if_spi_h2c(struct if_spi_card *card,
>  		port_reg = IF_SPI_CMD_RDWRPORT_REG;
>  		break;
>  	default:
> -		lbs_pr_err("can't transfer buffer of type %d\n", type);
> +		pr_err("can't transfer buffer of type %d\n", type);
>  		err = -EINVAL;
>  		goto out;
>  	}
> @@ -799,7 +792,7 @@ out:
>  	kfree(packet);
>  
>  	if (err)
> -		lbs_pr_err("%s: error %d\n", __func__, err);
> +		pr_err("%s: error %d\n", __func__, err);
>  }
>  
>  /* Inform the host about a card event */
> @@ -823,7 +816,7 @@ static void if_spi_e2h(struct if_spi_card *card)
>  	lbs_queue_event(priv, cause & 0xff);
>  out:
>  	if (err)
> -		lbs_pr_err("%s: error %d\n", __func__, err);
> +		pr_err("%s: error %d\n", __func__, err);
>  }
>  
>  static void if_spi_host_to_card_worker(struct work_struct *work)
> @@ -843,7 +836,7 @@ static void if_spi_host_to_card_worker(struct work_struct *work)
>  	err = spu_read_u16(card, IF_SPI_HOST_INT_STATUS_REG,
>  				&hiStatus);
>  	if (err) {
> -		lbs_pr_err("I/O error\n");
> +		pr_err("I/O error\n");
>  		goto err;
>  	}
>  
> @@ -905,7 +898,7 @@ static void if_spi_host_to_card_worker(struct work_struct *work)
>  
>  err:
>  	if (err)
> -		lbs_pr_err("%s: got error %d\n", __func__, err);
> +		pr_err("%s: got error %d\n", __func__, err);
>  
>  	lbs_deb_leave(LBS_DEB_SPI);
>  }
> @@ -927,7 +920,7 @@ static int if_spi_host_to_card(struct lbs_private *priv,
>  	lbs_deb_enter_args(LBS_DEB_SPI, "type %d, bytes %d", type, nb);
>  
>  	if (nb == 0) {
> -		lbs_pr_err("%s: invalid size requested: %d\n", __func__, nb);
> +		pr_err("%s: invalid size requested: %d\n", __func__, nb);
>  		err = -EINVAL;
>  		goto out;
>  	}
> @@ -955,7 +948,7 @@ static int if_spi_host_to_card(struct lbs_private *priv,
>  		spin_unlock_irqrestore(&card->buffer_lock, flags);
>  		break;
>  	default:
> -		lbs_pr_err("can't transfer buffer of type %d", type);
> +		pr_err("can't transfer buffer of type %d\n", type);
>  		err = -EINVAL;
>  		break;
>  	}
> @@ -1016,8 +1009,7 @@ static int if_spi_init_card(struct if_spi_card *card)
>  				break;
>  		}
>  		if (i == ARRAY_SIZE(fw_table)) {
> -			lbs_pr_err("Unsupported chip_id: 0x%02x\n",
> -					card->card_id);
> +			pr_err("Unsupported chip_id: 0x%02x\n", card->card_id);
>  			err = -ENODEV;
>  			goto out;
>  		}
> @@ -1026,7 +1018,7 @@ static int if_spi_init_card(struct if_spi_card *card)
>  					card->card_id, &fw_table[0], &helper,
>  					&mainfw);
>  		if (err) {
> -			lbs_pr_err("failed to find firmware (%d)\n", err);
> +			pr_err("failed to find firmware (%d)\n", err);
>  			goto out;
>  		}
>  
> @@ -1149,7 +1141,7 @@ static int __devinit if_spi_probe(struct spi_device *spi)
>  	err = request_irq(spi->irq, if_spi_host_interrupt,
>  			IRQF_TRIGGER_FALLING, "libertas_spi", card);
>  	if (err) {
> -		lbs_pr_err("can't get host irq line-- request_irq failed\n");
> +		pr_err("can't get host irq line-- request_irq failed\n");
>  		goto terminate_workqueue;
>  	}
>  
> diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
> index 6524c70..7260791 100644
> --- a/drivers/net/wireless/libertas/if_usb.c
> +++ b/drivers/net/wireless/libertas/if_usb.c
> @@ -1,6 +1,9 @@
>  /**
>    * This file contains functions used in USB interface module.
>    */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/delay.h>
>  #include <linux/moduleparam.h>
>  #include <linux/firmware.h>
> @@ -145,7 +148,7 @@ static void if_usb_write_bulk_callback(struct urb *urb)
>  			lbs_host_to_card_done(priv);
>  	} else {
>  		/* print the failure status number for debug */
> -		lbs_pr_info("URB in failure status: %d\n", urb->status);
> +		pr_info("URB in failure status: %d\n", urb->status);
>  	}
>  }
>  
> @@ -195,7 +198,7 @@ static void if_usb_setup_firmware(struct lbs_private *priv)
>  	wake_method.hdr.size = cpu_to_le16(sizeof(wake_method));
>  	wake_method.action = cpu_to_le16(CMD_ACT_GET);
>  	if (lbs_cmd_with_response(priv, CMD_802_11_FW_WAKE_METHOD, &wake_method)) {
> -		lbs_pr_info("Firmware does not seem to support PS mode\n");
> +		pr_info("Firmware does not seem to support PS mode\n");
>  		priv->fwcapinfo &= ~FW_CAPINFO_PS;
>  	} else {
>  		if (le16_to_cpu(wake_method.method) == CMD_WAKE_METHOD_COMMAND_INT) {
> @@ -204,7 +207,7 @@ static void if_usb_setup_firmware(struct lbs_private *priv)
>  			/* The versions which boot up this way don't seem to
>  			   work even if we set it to the command interrupt */
>  			priv->fwcapinfo &= ~FW_CAPINFO_PS;
> -			lbs_pr_info("Firmware doesn't wake via command interrupt; disabling PS mode\n");
> +			pr_info("Firmware doesn't wake via command interrupt; disabling PS mode\n");
>  		}
>  	}
>  }
> @@ -216,7 +219,7 @@ static void if_usb_fw_timeo(unsigned long priv)
>  	if (cardp->fwdnldover) {
>  		lbs_deb_usb("Download complete, no event. Assuming success\n");
>  	} else {
> -		lbs_pr_err("Download timed out\n");
> +		pr_err("Download timed out\n");
>  		cardp->surprise_removed = 1;
>  	}
>  	wake_up(&cardp->fw_wq);
> @@ -250,7 +253,7 @@ static int if_usb_probe(struct usb_interface *intf,
>  
>  	cardp = kzalloc(sizeof(struct if_usb_card), GFP_KERNEL);
>  	if (!cardp) {
> -		lbs_pr_err("Out of memory allocating private data.\n");
> +		pr_err("Out of memory allocating private data\n");
>  		goto error;
>  	}
>  
> @@ -340,10 +343,10 @@ static int if_usb_probe(struct usb_interface *intf,
>  	usb_set_intfdata(intf, cardp);
>  
>  	if (device_create_file(&priv->dev->dev, &dev_attr_lbs_flash_fw))
> -		lbs_pr_err("cannot register lbs_flash_fw attribute\n");
> +		pr_err("cannot register lbs_flash_fw attribute\n");
>  
>  	if (device_create_file(&priv->dev->dev, &dev_attr_lbs_flash_boot2))
> -		lbs_pr_err("cannot register lbs_flash_boot2 attribute\n");
> +		pr_err("cannot register lbs_flash_boot2 attribute\n");
>  
>  	/*
>  	 * EHS_REMOVE_WAKEUP is not supported on all versions of the firmware.
> @@ -528,7 +531,7 @@ static int __if_usb_submit_rx_urb(struct if_usb_card *cardp,
>  	int ret = -1;
>  
>  	if (!(skb = dev_alloc_skb(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE))) {
> -		lbs_pr_err("No free skb\n");
> +		pr_err("No free skb\n");
>  		goto rx_ret;
>  	}
>  
> @@ -587,7 +590,7 @@ static void if_usb_receive_fwload(struct urb *urb)
>  
>  		if (tmp[0] == cpu_to_le32(CMD_TYPE_INDICATION) &&
>  		    tmp[1] == cpu_to_le32(MACREG_INT_CODE_FIRMWARE_READY)) {
> -			lbs_pr_info("Firmware ready event received\n");
> +			pr_info("Firmware ready event received\n");
>  			wake_up(&cardp->fw_wq);
>  		} else {
>  			lbs_deb_usb("Waiting for confirmation; got %x %x\n",
> @@ -614,20 +617,20 @@ static void if_usb_receive_fwload(struct urb *urb)
>  			    bootcmdresp.magic == cpu_to_le32(CMD_TYPE_DATA) ||
>  			    bootcmdresp.magic == cpu_to_le32(CMD_TYPE_INDICATION)) {
>  				if (!cardp->bootcmdresp)
> -					lbs_pr_info("Firmware already seems alive; resetting\n");
> +					pr_info("Firmware already seems alive; resetting\n");
>  				cardp->bootcmdresp = -1;
>  			} else {
> -				lbs_pr_info("boot cmd response wrong magic number (0x%x)\n",
> +				pr_info("boot cmd response wrong magic number (0x%x)\n",
>  					    le32_to_cpu(bootcmdresp.magic));
>  			}
>  		} else if ((bootcmdresp.cmd != BOOT_CMD_FW_BY_USB) &&
>  			   (bootcmdresp.cmd != BOOT_CMD_UPDATE_FW) &&
>  			   (bootcmdresp.cmd != BOOT_CMD_UPDATE_BOOT2)) {
> -			lbs_pr_info("boot cmd response cmd_tag error (%d)\n",
> -				    bootcmdresp.cmd);
> +			pr_info("boot cmd response cmd_tag error (%d)\n",
> +				bootcmdresp.cmd);
>  		} else if (bootcmdresp.result != BOOT_CMD_RESP_OK) {
> -			lbs_pr_info("boot cmd response result error (%d)\n",
> -				    bootcmdresp.result);
> +			pr_info("boot cmd response result error (%d)\n",
> +				bootcmdresp.result);
>  		} else {
>  			cardp->bootcmdresp = 1;
>  			lbs_deb_usbd(&cardp->udev->dev,
> @@ -892,7 +895,7 @@ static int check_fwfile_format(const uint8_t *data, uint32_t totlen)
>  	} while (!exit);
>  
>  	if (ret)
> -		lbs_pr_err("firmware file format check FAIL\n");
> +		pr_err("firmware file format check FAIL\n");
>  	else
>  		lbs_deb_fw("firmware file format check PASS\n");
>  
> @@ -989,7 +992,7 @@ static int __if_usb_prog_firmware(struct if_usb_card *cardp,
>  
>  	ret = get_fw(cardp, fwname);
>  	if (ret) {
> -		lbs_pr_err("failed to find firmware (%d)\n", ret);
> +		pr_err("failed to find firmware (%d)\n", ret);
>  		goto done;
>  	}
>  
> @@ -1064,13 +1067,13 @@ restart:
>  	usb_kill_urb(cardp->rx_urb);
>  
>  	if (!cardp->fwdnldover) {
> -		lbs_pr_info("failed to load fw, resetting device!\n");
> +		pr_info("failed to load fw, resetting device!\n");
>  		if (--reset_count >= 0) {
>  			if_usb_reset_device(cardp);
>  			goto restart;
>  		}
>  
> -		lbs_pr_info("FW download failure, time = %d ms\n", i * 100);
> +		pr_info("FW download failure, time = %d ms\n", i * 100);
>  		ret = -EIO;
>  		goto release_fw;
>  	}
> diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
> index ca8149c..639461b 100644
> --- a/drivers/net/wireless/libertas/main.c
> +++ b/drivers/net/wireless/libertas/main.c
> @@ -4,6 +4,8 @@
>    * thread etc..
>    */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/moduleparam.h>
>  #include <linux/delay.h>
>  #include <linux/etherdevice.h>
> @@ -153,7 +155,7 @@ static void lbs_tx_timeout(struct net_device *dev)
>  
>  	lbs_deb_enter(LBS_DEB_TX);
>  
> -	lbs_pr_err("tx watch dog timeout\n");
> +	pr_err("tx watch dog timeout\n");
>  
>  	dev->trans_start = jiffies; /* prevent tx timeout */
>  
> @@ -462,7 +464,7 @@ static int lbs_thread(void *data)
>  		if (priv->cmd_timed_out && priv->cur_cmd) {
>  			struct cmd_ctrl_node *cmdnode = priv->cur_cmd;
>  
> -			lbs_pr_info("Timeout submitting command 0x%04x\n",
> +			pr_info("Timeout submitting command 0x%04x\n",
>  				le16_to_cpu(cmdnode->cmdbuf->command));
>  			lbs_complete_command(priv, cmdnode, -ETIMEDOUT);
>  			if (priv->reset_card)
> @@ -490,8 +492,7 @@ static int lbs_thread(void *data)
>  				 * after firmware fixes it
>  				 */
>  				priv->psstate = PS_STATE_AWAKE;
> -				lbs_pr_alert("ignore PS_SleepConfirm in "
> -					"non-connected state\n");
> +				pr_alert("ignore PS_SleepConfirm in non-connected state\n");
>  			}
>  		}
>  
> @@ -585,7 +586,7 @@ int lbs_suspend(struct lbs_private *priv)
>  	if (priv->is_deep_sleep) {
>  		ret = lbs_set_deep_sleep(priv, 0);
>  		if (ret) {
> -			lbs_pr_err("deep sleep cancellation failed: %d\n", ret);
> +			pr_err("deep sleep cancellation failed: %d\n", ret);
>  			return ret;
>  		}
>  		priv->deep_sleep_required = 1;
> @@ -618,7 +619,7 @@ int lbs_resume(struct lbs_private *priv)
>  		priv->deep_sleep_required = 0;
>  		ret = lbs_set_deep_sleep(priv, 1);
>  		if (ret)
> -			lbs_pr_err("deep sleep activation failed: %d\n", ret);
> +			pr_err("deep sleep activation failed: %d\n", ret);
>  	}
>  
>  	if (priv->setup_fw_on_resume)
> @@ -644,7 +645,7 @@ static void lbs_cmd_timeout_handler(unsigned long data)
>  	if (!priv->cur_cmd)
>  		goto out;
>  
> -	lbs_pr_info("command 0x%04x timed out\n",
> +	pr_info("command 0x%04x timed out\n",
>  		le16_to_cpu(priv->cur_cmd->cmdbuf->command));
>  
>  	priv->cmd_timed_out = 1;
> @@ -748,7 +749,7 @@ static int lbs_init_adapter(struct lbs_private *priv)
>  
>  	/* Allocate the command buffers */
>  	if (lbs_allocate_cmd_buffer(priv)) {
> -		lbs_pr_err("Out of memory allocating command buffers\n");
> +		pr_err("Out of memory allocating command buffers\n");
>  		ret = -ENOMEM;
>  		goto out;
>  	}
> @@ -758,7 +759,7 @@ static int lbs_init_adapter(struct lbs_private *priv)
>  	/* Create the event FIFO */
>  	ret = kfifo_alloc(&priv->event_fifo, sizeof(u32) * 16, GFP_KERNEL);
>  	if (ret) {
> -		lbs_pr_err("Out of memory allocating event FIFO buffer\n");
> +		pr_err("Out of memory allocating event FIFO buffer\n");
>  		goto out;
>  	}
>  
> @@ -809,7 +810,7 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
>  	/* Allocate an Ethernet device and register it */
>  	wdev = lbs_cfg_alloc(dmdev);
>  	if (IS_ERR(wdev)) {
> -		lbs_pr_err("cfg80211 init failed\n");
> +		pr_err("cfg80211 init failed\n");
>  		goto done;
>  	}
>  
> @@ -818,7 +819,7 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
>  	priv->wdev = wdev;
>  
>  	if (lbs_init_adapter(priv)) {
> -		lbs_pr_err("failed to initialize adapter structure.\n");
> +		pr_err("failed to initialize adapter structure\n");
>  		goto err_wdev;
>  	}
>  
> @@ -950,7 +951,7 @@ int lbs_start_card(struct lbs_private *priv)
>  		goto done;
>  
>  	if (lbs_cfg_register(priv)) {
> -		lbs_pr_err("cannot register device\n");
> +		pr_err("cannot register device\n");
>  		goto done;
>  	}
>  
> @@ -960,7 +961,7 @@ int lbs_start_card(struct lbs_private *priv)
>  
>  	lbs_debugfs_init_one(priv, dev);
>  
> -	lbs_pr_info("%s: Marvell WLAN 802.11 adapter\n", dev->name);
> +	pr_info("%s: Marvell WLAN 802.11 adapter\n", dev->name);
>  
>  	ret = 0;
>  
> @@ -1087,16 +1088,14 @@ int lbs_get_firmware(struct device *dev, const char *user_helper,
>  	if (user_helper) {
>  		ret = request_firmware(helper, user_helper, dev);
>  		if (ret) {
> -			lbs_pr_err("couldn't find helper firmware %s",
> -					user_helper);
> +			pr_err("couldn't find helper firmware %s", user_helper);
>  			goto fail;
>  		}
>  	}
>  	if (user_mainfw) {
>  		ret = request_firmware(mainfw, user_mainfw, dev);
>  		if (ret) {
> -			lbs_pr_err("couldn't find main firmware %s",
> -					user_mainfw);
> +			pr_err("couldn't find main firmware %s", user_mainfw);
>  			goto fail;
>  		}
>  	}
> diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c
> index 9d097b9..f7c51cb 100644
> --- a/drivers/net/wireless/libertas/mesh.c
> +++ b/drivers/net/wireless/libertas/mesh.c
> @@ -1,3 +1,5 @@
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/delay.h>
>  #include <linux/etherdevice.h>
>  #include <linux/netdevice.h>
> @@ -246,7 +248,7 @@ int lbs_init_mesh(struct lbs_private *priv)
>  		lbs_add_mesh(priv);
>  
>  		if (device_create_file(&dev->dev, &dev_attr_lbs_mesh))
> -			lbs_pr_err("cannot register lbs_mesh attribute\n");
> +			pr_err("cannot register lbs_mesh attribute\n");
>  
>  		ret = 1;
>  	}
> @@ -374,7 +376,7 @@ int lbs_add_mesh(struct lbs_private *priv)
>  	/* Register virtual mesh interface */
>  	ret = register_netdev(mesh_dev);
>  	if (ret) {
> -		lbs_pr_err("cannot register mshX virtual interface\n");
> +		pr_err("cannot register mshX virtual interface\n");
>  		goto err_free;
>  	}
>  
> @@ -926,7 +928,7 @@ static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
>  		return ret;
>  
>  	if (defs.meshie.val.mesh_id_len > IEEE80211_MAX_SSID_LEN) {
> -		lbs_pr_err("inconsistent mesh ID length");
> +		pr_err("inconsistent mesh ID length\n");
>  		defs.meshie.val.mesh_id_len = IEEE80211_MAX_SSID_LEN;
>  	}
>  
> diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c
> index a2b1df2..fd045aa 100644
> --- a/drivers/net/wireless/libertas/rx.c
> +++ b/drivers/net/wireless/libertas/rx.c
> @@ -1,6 +1,9 @@
>  /**
>    * This file contains the handling of RX in wlan driver.
>    */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/etherdevice.h>
>  #include <linux/slab.h>
>  #include <linux/types.h>
> @@ -191,7 +194,7 @@ static u8 convert_mv_rate_to_radiotap(u8 rate)
>  	case 12:		/*  54 Mbps */
>  		return 108;
>  	}
> -	lbs_pr_alert("Invalid Marvell WLAN rate %i\n", rate);
> +	pr_alert("Invalid Marvell WLAN rate %i\n", rate);
>  	return 0;
>  }
>  
> @@ -248,7 +251,7 @@ static int process_rxed_802_11_packet(struct lbs_private *priv,
>  	/* add space for the new radio header */
>  	if ((skb_headroom(skb) < sizeof(struct rx_radiotap_hdr)) &&
>  	    pskb_expand_head(skb, sizeof(struct rx_radiotap_hdr), 0, GFP_ATOMIC)) {
> -		lbs_pr_alert("%s: couldn't pskb_expand_head\n", __func__);
> +		pr_alert("%s: couldn't pskb_expand_head\n", __func__);
>  		ret = -ENOMEM;
>  		kfree_skb(skb);
>  		goto done;

^ permalink raw reply

* Re: [PATCH 2/2] libertas: Use netdev_<level> or dev_<level> where possible
From: Dan Williams @ 2011-05-04 22:15 UTC (permalink / raw)
  To: Joe Perches
  Cc: John W. Linville, libertas-dev, linux-wireless, netdev,
	linux-kernel
In-Reply-To: <b4b100451cb09b60065f2cf87b893b8d42759aaf.1304379925.git.joe@perches.com>

On Mon, 2011-05-02 at 16:49 -0700, Joe Perches wrote:
> Using the more descriptive logging styles gives a bit
> more information about the device being operated on.
> 
> Makes the object trivially smaller too.
> 
> $ size drivers/net/wireless/libertas/built-in.o.*
>  187730	   2973	  38488	 229191	  37f47	drivers/net/wireless/libertas/built-in.o.new
>  188195	   2973	  38488	 229656	  38118	drivers/net/wireless/libertas/built-in.o.old
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Acked-by: Dan Williams <dcbw@redhat.com>

> ---
>  drivers/net/wireless/libertas/cfg.c     |    9 +++--
>  drivers/net/wireless/libertas/cmd.c     |   42 +++++++++++++----------
>  drivers/net/wireless/libertas/cmdresp.c |   32 +++++++++---------
>  drivers/net/wireless/libertas/debugfs.c |    7 ++--
>  drivers/net/wireless/libertas/if_cs.c   |   15 +++++---
>  drivers/net/wireless/libertas/if_sdio.c |   19 +++++-----
>  drivers/net/wireless/libertas/if_spi.c  |   57 ++++++++++++++++++++-----------
>  drivers/net/wireless/libertas/if_usb.c  |   11 ++++--
>  drivers/net/wireless/libertas/main.c    |   27 +++++++++------
>  drivers/net/wireless/libertas/mesh.c    |    4 +-
>  drivers/net/wireless/libertas/rx.c      |    2 +-
>  11 files changed, 131 insertions(+), 94 deletions(-)
> 
> diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c
> index d6e0656..47b7f17 100644
> --- a/drivers/net/wireless/libertas/cfg.c
> +++ b/drivers/net/wireless/libertas/cfg.c
> @@ -1316,7 +1316,8 @@ static int lbs_cfg_connect(struct wiphy *wiphy, struct net_device *dev,
>  		sme->ssid, sme->ssid_len,
>  		WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
>  	if (!bss) {
> -		pr_err("assoc: bss %pM not in scan results\n", sme->bssid);
> +		wiphy_err(wiphy, "assoc: bss %pM not in scan results\n",
> +			  sme->bssid);
>  		ret = -ENOENT;
>  		goto done;
>  	}
> @@ -1373,8 +1374,8 @@ static int lbs_cfg_connect(struct wiphy *wiphy, struct net_device *dev,
>  		lbs_enable_rsn(priv, sme->crypto.cipher_group != 0);
>  		break;
>  	default:
> -		pr_err("unsupported cipher group 0x%x\n",
> -		       sme->crypto.cipher_group);
> +		wiphy_err(wiphy, "unsupported cipher group 0x%x\n",
> +			  sme->crypto.cipher_group);
>  		ret = -ENOTSUPP;
>  		goto done;
>  	}
> @@ -1492,7 +1493,7 @@ static int lbs_cfg_add_key(struct wiphy *wiphy, struct net_device *netdev,
>  				     params->key, params->key_len);
>  		break;
>  	default:
> -		pr_err("unhandled cipher 0x%x\n", params->cipher);
> +		wiphy_err(wiphy, "unhandled cipher 0x%x\n", params->cipher);
>  		ret = -ENOTSUPP;
>  		break;
>  	}
> diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
> index 10ca485..f11c656 100644
> --- a/drivers/net/wireless/libertas/cmd.c
> +++ b/drivers/net/wireless/libertas/cmd.c
> @@ -3,8 +3,6 @@
>    * It prepares command and sends it to firmware when it is ready.
>    */
>  
> -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> -
>  #include <linux/kfifo.h>
>  #include <linux/sched.h>
>  #include <linux/slab.h>
> @@ -110,7 +108,7 @@ int lbs_update_hw_spec(struct lbs_private *priv)
>  	 * CF card    firmware 5.0.16p0:   cap 0x00000303
>  	 * USB dongle firmware 5.110.17p2: cap 0x00000303
>  	 */
> -	pr_info("%pM, fw %u.%u.%up%u, cap 0x%08x\n",
> +	netdev_info(priv->dev, "%pM, fw %u.%u.%up%u, cap 0x%08x\n",
>  		cmd.permanentaddr,
>  		priv->fwrelease >> 24 & 0xff,
>  		priv->fwrelease >> 16 & 0xff,
> @@ -141,7 +139,8 @@ int lbs_update_hw_spec(struct lbs_private *priv)
>  	/* if it's unidentified region code, use the default (USA) */
>  	if (i >= MRVDRV_MAX_REGION_CODE) {
>  		priv->regioncode = 0x10;
> -		pr_info("unidentified region code; using the default (USA)\n");
> +		netdev_info(priv->dev,
> +			    "unidentified region code; using the default (USA)\n");
>  	}
>  
>  	if (priv->current_addr[0] == 0xff)
> @@ -211,7 +210,7 @@ int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria,
>  					(uint8_t *)&cmd_config.wol_conf,
>  					sizeof(struct wol_config));
>  	} else {
> -		pr_info("HOST_SLEEP_CFG failed %d\n", ret);
> +		netdev_info(priv->dev, "HOST_SLEEP_CFG failed %d\n", ret);
>  	}
>  
>  	return ret;
> @@ -314,7 +313,7 @@ static int lbs_wait_for_ds_awake(struct lbs_private *priv)
>  	if (priv->is_deep_sleep) {
>  		if (!wait_event_interruptible_timeout(priv->ds_awake_q,
>  					!priv->is_deep_sleep, (10 * HZ))) {
> -			pr_err("ds_awake_q: timer expired\n");
> +			netdev_err(priv->dev, "ds_awake_q: timer expired\n");
>  			ret = -1;
>  		}
>  	}
> @@ -339,7 +338,7 @@ int lbs_set_deep_sleep(struct lbs_private *priv, int deep_sleep)
>  				netif_carrier_off(priv->dev);
>  			}
>  		} else {
> -			pr_err("deep sleep: already enabled\n");
> +			netdev_err(priv->dev, "deep sleep: already enabled\n");
>  		}
>  	} else {
>  		if (priv->is_deep_sleep) {
> @@ -349,7 +348,8 @@ int lbs_set_deep_sleep(struct lbs_private *priv, int deep_sleep)
>  			if (!ret) {
>  				ret = lbs_wait_for_ds_awake(priv);
>  				if (ret)
> -					pr_err("deep sleep: wakeup failed\n");
> +					netdev_err(priv->dev,
> +						   "deep sleep: wakeup failed\n");
>  			}
>  		}
>  	}
> @@ -383,8 +383,9 @@ int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep)
>  			ret = lbs_host_sleep_cfg(priv, priv->wol_criteria,
>  					(struct wol_config *)NULL);
>  			if (ret) {
> -				pr_info("Host sleep configuration failed: %d\n",
> -					ret);
> +				netdev_info(priv->dev,
> +					    "Host sleep configuration failed: %d\n",
> +					    ret);
>  				return ret;
>  			}
>  			if (priv->psstate == PS_STATE_FULL_POWER) {
> @@ -394,19 +395,21 @@ int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep)
>  						sizeof(cmd),
>  						lbs_ret_host_sleep_activate, 0);
>  				if (ret)
> -					pr_info("HOST_SLEEP_ACTIVATE failed: %d\n",
> -						ret);
> +					netdev_info(priv->dev,
> +						    "HOST_SLEEP_ACTIVATE failed: %d\n",
> +						    ret);
>  			}
>  
>  			if (!wait_event_interruptible_timeout(
>  						priv->host_sleep_q,
>  						priv->is_host_sleep_activated,
>  						(10 * HZ))) {
> -				pr_err("host_sleep_q: timer expired\n");
> +				netdev_err(priv->dev,
> +					   "host_sleep_q: timer expired\n");
>  				ret = -1;
>  			}
>  		} else {
> -			pr_err("host sleep: already enabled\n");
> +			netdev_err(priv->dev, "host sleep: already enabled\n");
>  		}
>  	} else {
>  		if (priv->is_host_sleep_activated)
> @@ -1003,7 +1006,8 @@ static void lbs_submit_command(struct lbs_private *priv,
>  	ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize);
>  
>  	if (ret) {
> -		pr_info("DNLD_CMD: hw_host_to_card failed: %d\n", ret);
> +		netdev_info(priv->dev, "DNLD_CMD: hw_host_to_card failed: %d\n",
> +			    ret);
>  		/* Let the timer kick in and retry, and potentially reset
>  		   the whole thing if the condition persists */
>  		timeo = HZ/4;
> @@ -1268,7 +1272,8 @@ int lbs_execute_next_command(struct lbs_private *priv)
>  	spin_lock_irqsave(&priv->driver_lock, flags);
>  
>  	if (priv->cur_cmd) {
> -		pr_alert( "EXEC_NEXT_CMD: already processing command!\n");
> +		netdev_alert(priv->dev,
> +			     "EXEC_NEXT_CMD: already processing command!\n");
>  		spin_unlock_irqrestore(&priv->driver_lock, flags);
>  		ret = -1;
>  		goto done;
> @@ -1430,7 +1435,7 @@ static void lbs_send_confirmsleep(struct lbs_private *priv)
>  	ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) &confirm_sleep,
>  		sizeof(confirm_sleep));
>  	if (ret) {
> -		pr_alert("confirm_sleep failed\n");
> +		netdev_alert(priv->dev, "confirm_sleep failed\n");
>  		goto out;
>  	}
>  
> @@ -1656,7 +1661,8 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command,
>  	spin_lock_irqsave(&priv->driver_lock, flags);
>  	ret = cmdnode->result;
>  	if (ret)
> -		pr_info("PREP_CMD: command 0x%04x failed: %d\n", command, ret);
> +		netdev_info(priv->dev, "PREP_CMD: command 0x%04x failed: %d\n",
> +			    command, ret);
>  
>  	__lbs_cleanup_and_insert_cmd(priv, cmdnode);
>  	spin_unlock_irqrestore(&priv->driver_lock, flags);
> diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
> index 2cb6f5f..4352e92 100644
> --- a/drivers/net/wireless/libertas/cmdresp.c
> +++ b/drivers/net/wireless/libertas/cmdresp.c
> @@ -3,8 +3,6 @@
>    * responses as well as events generated by firmware.
>    */
>  
> -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> -
>  #include <linux/slab.h>
>  #include <linux/delay.h>
>  #include <linux/sched.h>
> @@ -87,17 +85,18 @@ int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len)
>  	lbs_deb_hex(LBS_DEB_CMD, "CMD_RESP", (void *) resp, len);
>  
>  	if (resp->seqnum != priv->cur_cmd->cmdbuf->seqnum) {
> -		pr_info("Received CMD_RESP with invalid sequence %d (expected %d)\n",
> -			le16_to_cpu(resp->seqnum),
> -			le16_to_cpu(priv->cur_cmd->cmdbuf->seqnum));
> +		netdev_info(priv->dev,
> +			    "Received CMD_RESP with invalid sequence %d (expected %d)\n",
> +			    le16_to_cpu(resp->seqnum),
> +			    le16_to_cpu(priv->cur_cmd->cmdbuf->seqnum));
>  		spin_unlock_irqrestore(&priv->driver_lock, flags);
>  		ret = -1;
>  		goto done;
>  	}
>  	if (respcmd != CMD_RET(curcmd) &&
>  	    respcmd != CMD_RET_802_11_ASSOCIATE && curcmd != CMD_802_11_ASSOCIATE) {
> -		pr_info("Invalid CMD_RESP %x to command %x!\n",
> -			respcmd, curcmd);
> +		netdev_info(priv->dev, "Invalid CMD_RESP %x to command %x!\n",
> +			    respcmd, curcmd);
>  		spin_unlock_irqrestore(&priv->driver_lock, flags);
>  		ret = -1;
>  		goto done;
> @@ -106,8 +105,9 @@ int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len)
>  	if (resp->result == cpu_to_le16(0x0004)) {
>  		/* 0x0004 means -EAGAIN. Drop the response, let it time out
>  		   and be resubmitted */
> -		pr_info("Firmware returns DEFER to command %x. Will let it time out...\n",
> -			le16_to_cpu(resp->command));
> +		netdev_info(priv->dev,
> +			    "Firmware returns DEFER to command %x. Will let it time out...\n",
> +			    le16_to_cpu(resp->command));
>  		spin_unlock_irqrestore(&priv->driver_lock, flags);
>  		ret = -1;
>  		goto done;
> @@ -318,28 +318,28 @@ int lbs_process_event(struct lbs_private *priv, u32 event)
>  		lbs_deb_cmd("EVENT: ADHOC beacon lost\n");
>  		break;
>  	case MACREG_INT_CODE_RSSI_LOW:
> -		pr_alert("EVENT: rssi low\n");
> +		netdev_alert(priv->dev, "EVENT: rssi low\n");
>  		break;
>  	case MACREG_INT_CODE_SNR_LOW:
> -		pr_alert("EVENT: snr low\n");
> +		netdev_alert(priv->dev, "EVENT: snr low\n");
>  		break;
>  	case MACREG_INT_CODE_MAX_FAIL:
> -		pr_alert("EVENT: max fail\n");
> +		netdev_alert(priv->dev, "EVENT: max fail\n");
>  		break;
>  	case MACREG_INT_CODE_RSSI_HIGH:
> -		pr_alert("EVENT: rssi high\n");
> +		netdev_alert(priv->dev, "EVENT: rssi high\n");
>  		break;
>  	case MACREG_INT_CODE_SNR_HIGH:
> -		pr_alert("EVENT: snr high\n");
> +		netdev_alert(priv->dev, "EVENT: snr high\n");
>  		break;
>  
>  	case MACREG_INT_CODE_MESH_AUTO_STARTED:
>  		/* Ignore spurious autostart events */
> -		pr_info("EVENT: MESH_AUTO_STARTED (ignoring)\n");
> +		netdev_info(priv->dev, "EVENT: MESH_AUTO_STARTED (ignoring)\n");
>  		break;
>  
>  	default:
> -		pr_alert("EVENT: unknown event id %d\n", event);
> +		netdev_alert(priv->dev, "EVENT: unknown event id %d\n", event);
>  		break;
>  	}
>  
> diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
> index c179094..f2f65bc 100644
> --- a/drivers/net/wireless/libertas/debugfs.c
> +++ b/drivers/net/wireless/libertas/debugfs.c
> @@ -1,5 +1,3 @@
> -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> -
>  #include <linux/dcache.h>
>  #include <linux/debugfs.h>
>  #include <linux/delay.h>
> @@ -153,13 +151,14 @@ static ssize_t lbs_host_sleep_write(struct file *file,
>  		ret = lbs_set_host_sleep(priv, 0);
>  	else if (host_sleep == 1) {
>  		if (priv->wol_criteria == EHS_REMOVE_WAKEUP) {
> -			pr_info("wake parameters not configured\n");
> +			netdev_info(priv->dev,
> +				    "wake parameters not configured\n");
>  			ret = -EINVAL;
>  			goto out_unlock;
>  		}
>  		ret = lbs_set_host_sleep(priv, 1);
>  	} else {
> -		pr_err("invalid option\n");
> +		netdev_err(priv->dev, "invalid option\n");
>  		ret = -EINVAL;
>  	}
>  
> diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
> index eb88d9a..d6f757e 100644
> --- a/drivers/net/wireless/libertas/if_cs.c
> +++ b/drivers/net/wireless/libertas/if_cs.c
> @@ -363,7 +363,7 @@ static int if_cs_send_cmd(struct lbs_private *priv, u8 *buf, u16 nb)
>  		if (status & IF_CS_BIT_COMMAND)
>  			break;
>  		if (++loops > 100) {
> -			pr_err("card not ready for commands\n");
> +			netdev_err(priv->dev, "card not ready for commands\n");
>  			goto done;
>  		}
>  		mdelay(1);
> @@ -433,14 +433,16 @@ static int if_cs_receive_cmdres(struct lbs_private *priv, u8 *data, u32 *len)
>  	/* is hardware ready? */
>  	status = if_cs_read16(priv->card, IF_CS_CARD_STATUS);
>  	if ((status & IF_CS_BIT_RESP) == 0) {
> -		pr_err("no cmd response in card\n");
> +		netdev_err(priv->dev, "no cmd response in card\n");
>  		*len = 0;
>  		goto out;
>  	}
>  
>  	*len = if_cs_read16(priv->card, IF_CS_RESP_LEN);
>  	if ((*len == 0) || (*len > LBS_CMD_BUFFER_SIZE)) {
> -		pr_err("card cmd buffer has invalid # of bytes (%d)\n", *len);
> +		netdev_err(priv->dev,
> +			   "card cmd buffer has invalid # of bytes (%d)\n",
> +			   *len);
>  		goto out;
>  	}
>  
> @@ -474,7 +476,9 @@ static struct sk_buff *if_cs_receive_data(struct lbs_private *priv)
>  
>  	len = if_cs_read16(priv->card, IF_CS_READ_LEN);
>  	if (len == 0 || len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) {
> -		pr_err("card data buffer has invalid # of bytes (%d)\n", len);
> +		netdev_err(priv->dev,
> +			   "card data buffer has invalid # of bytes (%d)\n",
> +			   len);
>  		priv->dev->stats.rx_dropped++;
>  		goto dat_err;
>  	}
> @@ -752,7 +756,8 @@ static int if_cs_host_to_card(struct lbs_private *priv,
>  		ret = if_cs_send_cmd(priv, buf, nb);
>  		break;
>  	default:
> -		pr_err("%s: unsupported type %d\n", __func__, type);
> +		netdev_err(priv->dev, "%s: unsupported type %d\n",
> +			   __func__, type);
>  	}
>  
>  	lbs_deb_leave_args(LBS_DEB_CS, "ret %d", ret);
> diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
> index ab86779..a7b5cb0 100644
> --- a/drivers/net/wireless/libertas/if_sdio.c
> +++ b/drivers/net/wireless/libertas/if_sdio.c
> @@ -851,7 +851,7 @@ static int if_sdio_enter_deep_sleep(struct lbs_private *priv)
>  	ret = __lbs_cmd(priv, CMD_802_11_DEEP_SLEEP, &cmd, sizeof(cmd),
>  			lbs_cmd_copyback, (unsigned long) &cmd);
>  	if (ret)
> -		pr_err("DEEP_SLEEP cmd failed\n");
> +		netdev_err(priv->dev, "DEEP_SLEEP cmd failed\n");
>  
>  	mdelay(200);
>  	return ret;
> @@ -867,7 +867,7 @@ static int if_sdio_exit_deep_sleep(struct lbs_private *priv)
>  
>  	sdio_writeb(card->func, HOST_POWER_UP, CONFIGURATION_REG, &ret);
>  	if (ret)
> -		pr_err("sdio_writeb failed!\n");
> +		netdev_err(priv->dev, "sdio_writeb failed!\n");
>  
>  	sdio_release_host(card->func);
>  	lbs_deb_leave_args(LBS_DEB_SDIO, "ret %d", ret);
> @@ -884,7 +884,7 @@ static int if_sdio_reset_deep_sleep_wakeup(struct lbs_private *priv)
>  
>  	sdio_writeb(card->func, 0, CONFIGURATION_REG, &ret);
>  	if (ret)
> -		pr_err("sdio_writeb failed!\n");
> +		netdev_err(priv->dev, "sdio_writeb failed!\n");
>  
>  	sdio_release_host(card->func);
>  	lbs_deb_leave_args(LBS_DEB_SDIO, "ret %d", ret);
> @@ -1103,7 +1103,7 @@ static int if_sdio_probe(struct sdio_func *func,
>  		lbs_deb_sdio("send function INIT command\n");
>  		if (__lbs_cmd(priv, CMD_FUNC_INIT, &cmd, sizeof(cmd),
>  				lbs_cmd_copyback, (unsigned long) &cmd))
> -			pr_alert("CMD_FUNC_INIT cmd failed\n");
> +			netdev_alert(priv->dev, "CMD_FUNC_INIT cmd failed\n");
>  	}
>  
>  	ret = lbs_start_card(priv);
> @@ -1204,19 +1204,20 @@ static int if_sdio_suspend(struct device *dev)
>  
>  	mmc_pm_flag_t flags = sdio_get_host_pm_caps(func);
>  
> -	pr_info("%s: suspend: PM flags = 0x%x\n", sdio_func_id(func), flags);
> +	dev_info(dev, "%s: suspend: PM flags = 0x%x\n",
> +		 sdio_func_id(func), flags);
>  
>  	/* If we aren't being asked to wake on anything, we should bail out
>  	 * and let the SD stack power down the card.
>  	 */
>  	if (card->priv->wol_criteria == EHS_REMOVE_WAKEUP) {
> -		pr_info("Suspend without wake params -- powering down card\n");
> +		dev_info(dev, "Suspend without wake params -- powering down card\n");
>  		return -ENOSYS;
>  	}
>  
>  	if (!(flags & MMC_PM_KEEP_POWER)) {
> -		pr_err("%s: cannot remain alive while host is suspended\n",
> -		       sdio_func_id(func));
> +		dev_err(dev, "%s: cannot remain alive while host is suspended\n",
> +			sdio_func_id(func));
>  		return -ENOSYS;
>  	}
>  
> @@ -1237,7 +1238,7 @@ static int if_sdio_resume(struct device *dev)
>  	struct if_sdio_card *card = sdio_get_drvdata(func);
>  	int ret;
>  
> -	pr_info("%s: resume: we're back\n", sdio_func_id(func));
> +	dev_info(dev, "%s: resume: we're back\n", sdio_func_id(func));
>  
>  	ret = lbs_resume(card->priv);
>  
> diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c
> index bebd9f0..30f21b1 100644
> --- a/drivers/net/wireless/libertas/if_spi.c
> +++ b/drivers/net/wireless/libertas/if_spi.c
> @@ -559,6 +559,7 @@ static int if_spi_prog_main_firmware_check_len(struct if_spi_card *card,
>  static int if_spi_prog_main_firmware(struct if_spi_card *card,
>  					const struct firmware *firmware)
>  {
> +	struct lbs_private *priv = card->priv;
>  	int len, prev_len;
>  	int bytes, crc_err = 0, err = 0;
>  	const u8 *fw;
> @@ -572,8 +573,9 @@ static int if_spi_prog_main_firmware(struct if_spi_card *card,
>  
>  	err = spu_wait_for_u16(card, IF_SPI_SCRATCH_1_REG, 0, 0);
>  	if (err) {
> -		pr_err("%s: timed out waiting for initial scratch reg = 0\n",
> -		       __func__);
> +		netdev_err(priv->dev,
> +			   "%s: timed out waiting for initial scratch reg = 0\n",
> +			   __func__);
>  		goto out;
>  	}
>  
> @@ -589,7 +591,8 @@ static int if_spi_prog_main_firmware(struct if_spi_card *card,
>  		if (bytes < 0) {
>  			/* If there are no more bytes left, we would normally
>  			 * expect to have terminated with len = 0 */
> -			pr_err("Firmware load wants more bytes than we have to offer\n");
> +			netdev_err(priv->dev,
> +				   "Firmware load wants more bytes than we have to offer\n");
>  			break;
>  		}
>  		if (crc_err) {
> @@ -674,12 +677,14 @@ static int if_spi_c2h_cmd(struct if_spi_card *card)
>  	if (err)
>  		goto out;
>  	if (!len) {
> -		pr_err("%s: error: card has no data for host\n", __func__);
> +		netdev_err(priv->dev, "%s: error: card has no data for host\n",
> +			   __func__);
>  		err = -EINVAL;
>  		goto out;
>  	} else if (len > IF_SPI_CMD_BUF_SIZE) {
> -		pr_err("%s: error: response packet too large: %d bytes, but maximum is %d\n",
> -		       __func__, len, IF_SPI_CMD_BUF_SIZE);
> +		netdev_err(priv->dev,
> +			   "%s: error: response packet too large: %d bytes, but maximum is %d\n",
> +			   __func__, len, IF_SPI_CMD_BUF_SIZE);
>  		err = -EINVAL;
>  		goto out;
>  	}
> @@ -700,7 +705,7 @@ static int if_spi_c2h_cmd(struct if_spi_card *card)
>  
>  out:
>  	if (err)
> -		pr_err("%s: err=%d\n", __func__, err);
> +		netdev_err(priv->dev, "%s: err=%d\n", __func__, err);
>  	lbs_deb_leave(LBS_DEB_SPI);
>  	return err;
>  }
> @@ -708,6 +713,7 @@ out:
>  /* Move data from the card to the host */
>  static int if_spi_c2h_data(struct if_spi_card *card)
>  {
> +	struct lbs_private *priv = card->priv;
>  	struct sk_buff *skb;
>  	char *data;
>  	u16 len;
> @@ -720,12 +726,14 @@ static int if_spi_c2h_data(struct if_spi_card *card)
>  	if (err)
>  		goto out;
>  	if (!len) {
> -		pr_err("%s: error: card has no data for host\n", __func__);
> +		netdev_err(priv->dev, "%s: error: card has no data for host\n",
> +			   __func__);
>  		err = -EINVAL;
>  		goto out;
>  	} else if (len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) {
> -		pr_err("%s: error: card has %d bytes of data, but our maximum skb size is %zu\n",
> -		       __func__, len, MRVDRV_ETH_RX_PACKET_BUFFER_SIZE);
> +		netdev_err(priv->dev,
> +			   "%s: error: card has %d bytes of data, but our maximum skb size is %zu\n",
> +			   __func__, len, MRVDRV_ETH_RX_PACKET_BUFFER_SIZE);
>  		err = -EINVAL;
>  		goto out;
>  	}
> @@ -756,7 +764,7 @@ free_skb:
>  	dev_kfree_skb(skb);
>  out:
>  	if (err)
> -		pr_err("%s: err=%d\n", __func__, err);
> +		netdev_err(priv->dev, "%s: err=%d\n", __func__, err);
>  	lbs_deb_leave(LBS_DEB_SPI);
>  	return err;
>  }
> @@ -765,6 +773,7 @@ out:
>  static void if_spi_h2c(struct if_spi_card *card,
>  			struct if_spi_packet *packet, int type)
>  {
> +	struct lbs_private *priv = card->priv;
>  	int err = 0;
>  	u16 int_type, port_reg;
>  
> @@ -778,7 +787,8 @@ static void if_spi_h2c(struct if_spi_card *card,
>  		port_reg = IF_SPI_CMD_RDWRPORT_REG;
>  		break;
>  	default:
> -		pr_err("can't transfer buffer of type %d\n", type);
> +		netdev_err(priv->dev, "can't transfer buffer of type %d\n",
> +			   type);
>  		err = -EINVAL;
>  		goto out;
>  	}
> @@ -792,7 +802,7 @@ out:
>  	kfree(packet);
>  
>  	if (err)
> -		pr_err("%s: error %d\n", __func__, err);
> +		netdev_err(priv->dev, "%s: error %d\n", __func__, err);
>  }
>  
>  /* Inform the host about a card event */
> @@ -816,7 +826,7 @@ static void if_spi_e2h(struct if_spi_card *card)
>  	lbs_queue_event(priv, cause & 0xff);
>  out:
>  	if (err)
> -		pr_err("%s: error %d\n", __func__, err);
> +		netdev_err(priv->dev, "%s: error %d\n", __func__, err);
>  }
>  
>  static void if_spi_host_to_card_worker(struct work_struct *work)
> @@ -826,8 +836,10 @@ static void if_spi_host_to_card_worker(struct work_struct *work)
>  	u16 hiStatus;
>  	unsigned long flags;
>  	struct if_spi_packet *packet;
> +	struct lbs_private *priv;
>  
>  	card = container_of(work, struct if_spi_card, packet_work);
> +	priv = card->priv;
>  
>  	lbs_deb_enter(LBS_DEB_SPI);
>  
> @@ -836,7 +848,7 @@ static void if_spi_host_to_card_worker(struct work_struct *work)
>  	err = spu_read_u16(card, IF_SPI_HOST_INT_STATUS_REG,
>  				&hiStatus);
>  	if (err) {
> -		pr_err("I/O error\n");
> +		netdev_err(priv->dev, "I/O error\n");
>  		goto err;
>  	}
>  
> @@ -898,7 +910,7 @@ static void if_spi_host_to_card_worker(struct work_struct *work)
>  
>  err:
>  	if (err)
> -		pr_err("%s: got error %d\n", __func__, err);
> +		netdev_err(priv->dev, "%s: got error %d\n", __func__, err);
>  
>  	lbs_deb_leave(LBS_DEB_SPI);
>  }
> @@ -920,7 +932,8 @@ static int if_spi_host_to_card(struct lbs_private *priv,
>  	lbs_deb_enter_args(LBS_DEB_SPI, "type %d, bytes %d", type, nb);
>  
>  	if (nb == 0) {
> -		pr_err("%s: invalid size requested: %d\n", __func__, nb);
> +		netdev_err(priv->dev, "%s: invalid size requested: %d\n",
> +			   __func__, nb);
>  		err = -EINVAL;
>  		goto out;
>  	}
> @@ -948,7 +961,8 @@ static int if_spi_host_to_card(struct lbs_private *priv,
>  		spin_unlock_irqrestore(&card->buffer_lock, flags);
>  		break;
>  	default:
> -		pr_err("can't transfer buffer of type %d\n", type);
> +		netdev_err(priv->dev, "can't transfer buffer of type %d\n",
> +			   type);
>  		err = -EINVAL;
>  		break;
>  	}
> @@ -981,6 +995,7 @@ static irqreturn_t if_spi_host_interrupt(int irq, void *dev_id)
>  
>  static int if_spi_init_card(struct if_spi_card *card)
>  {
> +	struct lbs_private *priv = card->priv;
>  	struct spi_device *spi = card->spi;
>  	int err, i;
>  	u32 scratch;
> @@ -1009,7 +1024,8 @@ static int if_spi_init_card(struct if_spi_card *card)
>  				break;
>  		}
>  		if (i == ARRAY_SIZE(fw_table)) {
> -			pr_err("Unsupported chip_id: 0x%02x\n", card->card_id);
> +			netdev_err(priv->dev, "Unsupported chip_id: 0x%02x\n",
> +				   card->card_id);
>  			err = -ENODEV;
>  			goto out;
>  		}
> @@ -1018,7 +1034,8 @@ static int if_spi_init_card(struct if_spi_card *card)
>  					card->card_id, &fw_table[0], &helper,
>  					&mainfw);
>  		if (err) {
> -			pr_err("failed to find firmware (%d)\n", err);
> +			netdev_err(priv->dev, "failed to find firmware (%d)\n",
> +				   err);
>  			goto out;
>  		}
>  
> diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
> index 7260791..63e7e2c 100644
> --- a/drivers/net/wireless/libertas/if_usb.c
> +++ b/drivers/net/wireless/libertas/if_usb.c
> @@ -198,7 +198,7 @@ static void if_usb_setup_firmware(struct lbs_private *priv)
>  	wake_method.hdr.size = cpu_to_le16(sizeof(wake_method));
>  	wake_method.action = cpu_to_le16(CMD_ACT_GET);
>  	if (lbs_cmd_with_response(priv, CMD_802_11_FW_WAKE_METHOD, &wake_method)) {
> -		pr_info("Firmware does not seem to support PS mode\n");
> +		netdev_info(priv->dev, "Firmware does not seem to support PS mode\n");
>  		priv->fwcapinfo &= ~FW_CAPINFO_PS;
>  	} else {
>  		if (le16_to_cpu(wake_method.method) == CMD_WAKE_METHOD_COMMAND_INT) {
> @@ -207,7 +207,8 @@ static void if_usb_setup_firmware(struct lbs_private *priv)
>  			/* The versions which boot up this way don't seem to
>  			   work even if we set it to the command interrupt */
>  			priv->fwcapinfo &= ~FW_CAPINFO_PS;
> -			pr_info("Firmware doesn't wake via command interrupt; disabling PS mode\n");
> +			netdev_info(priv->dev,
> +				    "Firmware doesn't wake via command interrupt; disabling PS mode\n");
>  		}
>  	}
>  }
> @@ -343,10 +344,12 @@ static int if_usb_probe(struct usb_interface *intf,
>  	usb_set_intfdata(intf, cardp);
>  
>  	if (device_create_file(&priv->dev->dev, &dev_attr_lbs_flash_fw))
> -		pr_err("cannot register lbs_flash_fw attribute\n");
> +		netdev_err(priv->dev,
> +			   "cannot register lbs_flash_fw attribute\n");
>  
>  	if (device_create_file(&priv->dev->dev, &dev_attr_lbs_flash_boot2))
> -		pr_err("cannot register lbs_flash_boot2 attribute\n");
> +		netdev_err(priv->dev,
> +			   "cannot register lbs_flash_boot2 attribute\n");
>  
>  	/*
>  	 * EHS_REMOVE_WAKEUP is not supported on all versions of the firmware.
> diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
> index 639461b..84ffafe 100644
> --- a/drivers/net/wireless/libertas/main.c
> +++ b/drivers/net/wireless/libertas/main.c
> @@ -155,7 +155,7 @@ static void lbs_tx_timeout(struct net_device *dev)
>  
>  	lbs_deb_enter(LBS_DEB_TX);
>  
> -	pr_err("tx watch dog timeout\n");
> +	netdev_err(dev, "tx watch dog timeout\n");
>  
>  	dev->trans_start = jiffies; /* prevent tx timeout */
>  
> @@ -464,8 +464,8 @@ static int lbs_thread(void *data)
>  		if (priv->cmd_timed_out && priv->cur_cmd) {
>  			struct cmd_ctrl_node *cmdnode = priv->cur_cmd;
>  
> -			pr_info("Timeout submitting command 0x%04x\n",
> -				le16_to_cpu(cmdnode->cmdbuf->command));
> +			netdev_info(dev, "Timeout submitting command 0x%04x\n",
> +				    le16_to_cpu(cmdnode->cmdbuf->command));
>  			lbs_complete_command(priv, cmdnode, -ETIMEDOUT);
>  			if (priv->reset_card)
>  				priv->reset_card(priv);
> @@ -492,7 +492,8 @@ static int lbs_thread(void *data)
>  				 * after firmware fixes it
>  				 */
>  				priv->psstate = PS_STATE_AWAKE;
> -				pr_alert("ignore PS_SleepConfirm in non-connected state\n");
> +				netdev_alert(dev,
> +					     "ignore PS_SleepConfirm in non-connected state\n");
>  			}
>  		}
>  
> @@ -586,7 +587,8 @@ int lbs_suspend(struct lbs_private *priv)
>  	if (priv->is_deep_sleep) {
>  		ret = lbs_set_deep_sleep(priv, 0);
>  		if (ret) {
> -			pr_err("deep sleep cancellation failed: %d\n", ret);
> +			netdev_err(priv->dev,
> +				   "deep sleep cancellation failed: %d\n", ret);
>  			return ret;
>  		}
>  		priv->deep_sleep_required = 1;
> @@ -619,7 +621,8 @@ int lbs_resume(struct lbs_private *priv)
>  		priv->deep_sleep_required = 0;
>  		ret = lbs_set_deep_sleep(priv, 1);
>  		if (ret)
> -			pr_err("deep sleep activation failed: %d\n", ret);
> +			netdev_err(priv->dev,
> +				   "deep sleep activation failed: %d\n", ret);
>  	}
>  
>  	if (priv->setup_fw_on_resume)
> @@ -645,8 +648,8 @@ static void lbs_cmd_timeout_handler(unsigned long data)
>  	if (!priv->cur_cmd)
>  		goto out;
>  
> -	pr_info("command 0x%04x timed out\n",
> -		le16_to_cpu(priv->cur_cmd->cmdbuf->command));
> +	netdev_info(priv->dev, "command 0x%04x timed out\n",
> +		    le16_to_cpu(priv->cur_cmd->cmdbuf->command));
>  
>  	priv->cmd_timed_out = 1;
>  	wake_up_interruptible(&priv->waitq);
> @@ -961,7 +964,7 @@ int lbs_start_card(struct lbs_private *priv)
>  
>  	lbs_debugfs_init_one(priv, dev);
>  
> -	pr_info("%s: Marvell WLAN 802.11 adapter\n", dev->name);
> +	netdev_info(dev, "Marvell WLAN 802.11 adapter\n");
>  
>  	ret = 0;
>  
> @@ -1088,14 +1091,16 @@ int lbs_get_firmware(struct device *dev, const char *user_helper,
>  	if (user_helper) {
>  		ret = request_firmware(helper, user_helper, dev);
>  		if (ret) {
> -			pr_err("couldn't find helper firmware %s", user_helper);
> +			dev_err(dev, "couldn't find helper firmware %s\n",
> +				user_helper);
>  			goto fail;
>  		}
>  	}
>  	if (user_mainfw) {
>  		ret = request_firmware(mainfw, user_mainfw, dev);
>  		if (ret) {
> -			pr_err("couldn't find main firmware %s", user_mainfw);
> +			dev_err(dev, "couldn't find main firmware %s\n",
> +				user_mainfw);
>  			goto fail;
>  		}
>  	}
> diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c
> index f7c51cb..f4c4f1c 100644
> --- a/drivers/net/wireless/libertas/mesh.c
> +++ b/drivers/net/wireless/libertas/mesh.c
> @@ -248,7 +248,7 @@ int lbs_init_mesh(struct lbs_private *priv)
>  		lbs_add_mesh(priv);
>  
>  		if (device_create_file(&dev->dev, &dev_attr_lbs_mesh))
> -			pr_err("cannot register lbs_mesh attribute\n");
> +			netdev_err(dev, "cannot register lbs_mesh attribute\n");
>  
>  		ret = 1;
>  	}
> @@ -928,7 +928,7 @@ static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
>  		return ret;
>  
>  	if (defs.meshie.val.mesh_id_len > IEEE80211_MAX_SSID_LEN) {
> -		pr_err("inconsistent mesh ID length\n");
> +		dev_err(dev, "inconsistent mesh ID length\n");
>  		defs.meshie.val.mesh_id_len = IEEE80211_MAX_SSID_LEN;
>  	}
>  
> diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c
> index fd045aa..f2ef0ae 100644
> --- a/drivers/net/wireless/libertas/rx.c
> +++ b/drivers/net/wireless/libertas/rx.c
> @@ -251,7 +251,7 @@ static int process_rxed_802_11_packet(struct lbs_private *priv,
>  	/* add space for the new radio header */
>  	if ((skb_headroom(skb) < sizeof(struct rx_radiotap_hdr)) &&
>  	    pskb_expand_head(skb, sizeof(struct rx_radiotap_hdr), 0, GFP_ATOMIC)) {
> -		pr_alert("%s: couldn't pskb_expand_head\n", __func__);
> +		netdev_alert(dev, "%s: couldn't pskb_expand_head\n", __func__);
>  		ret = -ENOMEM;
>  		kfree_skb(skb);
>  		goto done;

^ permalink raw reply

* [PATCH] net/bonding: bonding: Adjust coding style for bond_3ad files.
From: Rafael Azenha Aquini @ 2011-05-04 22:18 UTC (permalink / raw)
  To: kernel-janitors.vger.kernel.org; +Cc: Jay Vosburgh, Andy Gospodarek, netdev

Howdy,

While I was studying the code under the bond_3ad hood I realized that its coding
style did not follow all Documentation/CodingStyle recommendations. As a tiny
collaboration I did some mods there, in an attempt to make that code stick as
closely as possible with the Kernel coding style.

Signed-off-by: Rafael Aquini <aquini@linux.com>

---
 drivers/net/bonding/bond_3ad.c |  918 +++++++++++++++++++++++-----------------
 drivers/net/bonding/bond_3ad.h |  189 +++++----
 2 files changed, 633 insertions(+), 474 deletions(-)

diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 31912f1..97e7528 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -34,14 +34,14 @@
 #include "bonding.h"
 #include "bond_3ad.h"
 
-// General definitions
+/* General definitions */
 #define AD_SHORT_TIMEOUT           1
 #define AD_LONG_TIMEOUT            0
 #define AD_STANDBY                 0x2
 #define AD_MAX_TX_IN_SECOND        3
 #define AD_COLLECTOR_MAX_DELAY     0
 
-// Timer definitions(43.4.4 in the 802.3ad standard)
+/* Timer definitions(43.4.4 in the 802.3ad standard) */
 #define AD_FAST_PERIODIC_TIME      1
 #define AD_SLOW_PERIODIC_TIME      30
 #define AD_SHORT_TIMEOUT_TIME      (3*AD_FAST_PERIODIC_TIME)
@@ -49,7 +49,7 @@
 #define AD_CHURN_DETECTION_TIME    60
 #define AD_AGGREGATE_WAIT_TIME     2
 
-// Port state definitions(43.4.2.2 in the 802.3ad standard)
+/* Port state definitions(43.4.2.2 in the 802.3ad standard) */
 #define AD_STATE_LACP_ACTIVITY   0x1
 #define AD_STATE_LACP_TIMEOUT    0x2
 #define AD_STATE_AGGREGATION     0x4
@@ -59,7 +59,10 @@
 #define AD_STATE_DEFAULTED       0x40
 #define AD_STATE_EXPIRED         0x80
 
-// Port Variables definitions used by the State Machines(43.4.7 in the 802.3ad standard)
+/*
+ * Port Variables definitions used by the State
+ * Machines (43.4.7 in the 802.3ad standard)
+ */
 #define AD_PORT_BEGIN           0x1
 #define AD_PORT_LACP_ENABLED    0x2
 #define AD_PORT_ACTOR_CHURN     0x4
@@ -71,26 +74,25 @@
 #define AD_PORT_SELECTED        0x100
 #define AD_PORT_MOVED           0x200
 
-// Port Key definitions
-// key is determined according to the link speed, duplex and
-// user key(which is yet not supported)
-//              ------------------------------------------------------------
-// Port key :   | User key                       |      Speed       |Duplex|
-//              ------------------------------------------------------------
-//              16                               6               1 0
+/*
+ * Port Key definitions:
+ *  key is determined according to the link speed, duplex and
+ *  user key (which is yet not supported)
+ *             ------------------------------------------------------------
+ *  Port key:  | User key                       |      Speed       |Duplex|
+ *             ------------------------------------------------------------
+ *             16                               6                  1      0
+ */
 #define  AD_DUPLEX_KEY_BITS    0x1
 #define  AD_SPEED_KEY_BITS     0x3E
 #define  AD_USER_KEY_BITS      0xFFC0
 
-//dalloun
 #define     AD_LINK_SPEED_BITMASK_1MBPS       0x1
 #define     AD_LINK_SPEED_BITMASK_10MBPS      0x2
 #define     AD_LINK_SPEED_BITMASK_100MBPS     0x4
 #define     AD_LINK_SPEED_BITMASK_1000MBPS    0x8
 #define     AD_LINK_SPEED_BITMASK_10000MBPS   0x10
-//endalloun
 
-// compare MAC addresses
 #define MAC_ADDRESS_COMPARE(A, B) memcmp(A, B, ETH_ALEN)
 
 static struct mac_addr null_mac_addr = { { 0, 0, 0, 0, 0, 0 } };
@@ -99,7 +101,7 @@ static const int ad_delta_in_ticks = (AD_TIMER_INTERVAL * HZ) / 1000;
 
 static const u8 lacpdu_mcast_addr[ETH_ALEN] = MULTICAST_LACPDU_ADDR;
 
-// ================= main 802.3ad protocol functions ==================
+/* ================= main 802.3ad protocol functions ================== */
 static int ad_lacpdu_send(struct port *port);
 static int ad_marker_send(struct port *port, struct bond_marker *marker);
 static void ad_mux_machine(struct port *port);
@@ -113,14 +115,12 @@ static void ad_initialize_agg(struct aggregator *aggregator);
 static void ad_initialize_port(struct port *port, int lacp_fast);
 static void ad_enable_collecting_distributing(struct port *port);
 static void ad_disable_collecting_distributing(struct port *port);
-static void ad_marker_info_received(struct bond_marker *marker_info, struct port *port);
-static void ad_marker_response_received(struct bond_marker *marker, struct port *port);
-
-
-/////////////////////////////////////////////////////////////////////////////////
-// ================= api to bonding and kernel code ==================
-/////////////////////////////////////////////////////////////////////////////////
+static void ad_marker_info_received(struct bond_marker *marker_info,
+							struct port *port);
+static void ad_marker_response_received(struct bond_marker *marker,
+							struct port *port);
 
+/* ================= api to bonding and kernel code ================== */
 /**
  * __get_bond_by_port - get the port's bonding struct
  * @port: the port we're looking at
@@ -161,7 +161,6 @@ static inline struct port *__get_next_port(struct port *port)
 	struct bonding *bond = __get_bond_by_port(port);
 	struct slave *slave = port->slave;
 
-	// If there's no bond for this port, or this is the last slave
 	if ((bond == NULL) || (slave->next == bond->first_slave))
 		return NULL;
 
@@ -179,7 +178,6 @@ static inline struct aggregator *__get_first_agg(struct port *port)
 {
 	struct bonding *bond = __get_bond_by_port(port);
 
-	// If there's no bond for this port, or bond has no slaves
 	if ((bond == NULL) || (bond->slave_cnt == 0))
 		return NULL;
 
@@ -198,7 +196,6 @@ static inline struct aggregator *__get_next_agg(struct aggregator *aggregator)
 	struct slave *slave = aggregator->slave;
 	struct bonding *bond = bond_get_bond_by_slave(slave);
 
-	// If there's no bond for this aggregator, or this is the last slave
 	if ((bond == NULL) || (slave->next == bond->first_slave))
 		return NULL;
 
@@ -316,10 +313,12 @@ static u16 __get_link_speed(struct port *port)
 	struct slave *slave = port->slave;
 	u16 speed;
 
-	/* this if covers only a special case: when the configuration starts with
-	 * link down, it sets the speed to 0.
-	 * This is done in spite of the fact that the e100 driver reports 0 to be
-	 * compatible with MVT in the future.*/
+	/*
+	 * this if covers only a special case: when the configuration
+	 * starts with link down, it sets the speed to 0.
+	 * This is done in spite of the fact that the e100 driver
+	 * reports 0 to be compatible with MVT in the future.
+	 */
 	if (slave->link != BOND_LINK_UP)
 		speed = 0;
 	else {
@@ -341,13 +340,14 @@ static u16 __get_link_speed(struct port *port)
 			break;
 
 		default:
-			speed = 0; // unknown speed value from ethtool. shouldn't happen
+			/* unknown speed value from ethtool. shouldn't happen */
+			speed = 0;
 			break;
 		}
 	}
 
 	pr_debug("Port %d Received link speed %d update from adapter\n",
-		 port->actor_port_number, speed);
+						port->actor_port_number, speed);
 	return speed;
 }
 
@@ -365,22 +365,26 @@ static u8 __get_duplex(struct port *port)
 
 	u8 retval;
 
-	//  handling a special case: when the configuration starts with
-	// link down, it sets the duplex to 0.
+	/*
+	 * handling a special case: when the configuration starts with
+	 * link down, it sets the duplex to 0.
+	 */
 	if (slave->link != BOND_LINK_UP)
 		retval = 0x0;
 	else {
 		switch (slave->duplex) {
 		case DUPLEX_FULL:
 			retval = 0x1;
-			pr_debug("Port %d Received status full duplex update from adapter\n",
-				 port->actor_port_number);
+			pr_debug("Port %d Received status "
+					"full duplex update from adapter\n",
+					port->actor_port_number);
 			break;
 		case DUPLEX_HALF:
 		default:
 			retval = 0x0;
-			pr_debug("Port %d Received status NOT full duplex update from adapter\n",
-				 port->actor_port_number);
+			pr_debug("Port %d Received status NOT full "
+					"duplex update from adapter\n",
+					port->actor_port_number);
 			break;
 		}
 	}
@@ -394,12 +398,9 @@ static u8 __get_duplex(struct port *port)
  */
 static inline void __initialize_port_locks(struct port *port)
 {
-	// make sure it isn't called twice
 	spin_lock_init(&(SLAVE_AD_INFO(port->slave).state_machine_lock));
 }
 
-//conversions
-
 /**
  * __ad_timer_to_ticks - convert a given timer type to AD module ticks
  * @timer_type:	which timer to operate
@@ -411,36 +412,32 @@ static inline void __initialize_port_locks(struct port *port)
  */
 static u16 __ad_timer_to_ticks(u16 timer_type, u16 par)
 {
-	u16 retval = 0; /* to silence the compiler */
+	u16 retval = 0;
 
 	switch (timer_type) {
-	case AD_CURRENT_WHILE_TIMER:   // for rx machine usage
+	case AD_CURRENT_WHILE_TIMER:	/* for rx machine usage */
 		if (par)
-			retval = (AD_SHORT_TIMEOUT_TIME*ad_ticks_per_sec); // short timeout
+			retval = (AD_SHORT_TIMEOUT_TIME*ad_ticks_per_sec);
 		else
-			retval = (AD_LONG_TIMEOUT_TIME*ad_ticks_per_sec); // long timeout
+			retval = (AD_LONG_TIMEOUT_TIME*ad_ticks_per_sec);
 		break;
-	case AD_ACTOR_CHURN_TIMER:	    // for local churn machine
+	case AD_ACTOR_CHURN_TIMER:	/* for local churn machine */
 		retval = (AD_CHURN_DETECTION_TIME*ad_ticks_per_sec);
 		break;
-	case AD_PERIODIC_TIMER:	    // for periodic machine
-		retval = (par*ad_ticks_per_sec); // long timeout
+	case AD_PERIODIC_TIMER:		/* for periodic machine */
+		retval = (par*ad_ticks_per_sec);
 		break;
-	case AD_PARTNER_CHURN_TIMER:   // for remote churn machine
+	case AD_PARTNER_CHURN_TIMER:	/* for remote churn machine */
 		retval = (AD_CHURN_DETECTION_TIME*ad_ticks_per_sec);
 		break;
-	case AD_WAIT_WHILE_TIMER:	    // for selection machine
+	case AD_WAIT_WHILE_TIMER:	/* for selection machine */
 		retval = (AD_AGGREGATE_WAIT_TIME*ad_ticks_per_sec);
 		break;
 	}
 	return retval;
 }
 
-
-/////////////////////////////////////////////////////////////////////////////////
-// ================= ad_rx_machine helper functions ==================
-/////////////////////////////////////////////////////////////////////////////////
-
+/* ================= ad_rx_machine helper functions ================== */
 /**
  * __choose_matched - update a port's matched variable from a received lacpdu
  * @lacpdu: the lacpdu we've received
@@ -466,17 +463,17 @@ static u16 __ad_timer_to_ticks(u16 timer_type, u16 par)
  */
 static void __choose_matched(struct lacpdu *lacpdu, struct port *port)
 {
-	// check if all parameters are alike
 	if (((ntohs(lacpdu->partner_port) == port->actor_port_number) &&
-	     (ntohs(lacpdu->partner_port_priority) == port->actor_port_priority) &&
-	     !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) &&
-	     (ntohs(lacpdu->partner_system_priority) == port->actor_system_priority) &&
-	     (ntohs(lacpdu->partner_key) == port->actor_oper_port_key) &&
-	     ((lacpdu->partner_state & AD_STATE_AGGREGATION) == (port->actor_oper_port_state & AD_STATE_AGGREGATION))) ||
-	    // or this is individual link(aggregation == FALSE)
-	    ((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0)
-		) {
-		// update the state machine Matched variable
+	     (ntohs(lacpdu->partner_port_priority) == port->actor_port_priority)
+	    && !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system),
+							&(port->actor_system))
+	    && (ntohs(lacpdu->partner_system_priority) ==
+						   port->actor_system_priority)
+	    && (ntohs(lacpdu->partner_key) == port->actor_oper_port_key)
+	    && ((lacpdu->partner_state & AD_STATE_AGGREGATION) ==
+			(port->actor_oper_port_state & AD_STATE_AGGREGATION)))
+	    || ((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0)) {
+		/* update the state machine Selected variable */
 		port->sm_vars |= AD_PORT_MATCHED;
 	} else {
 		port->sm_vars &= ~AD_PORT_MATCHED;
@@ -498,7 +495,7 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
 		struct port_params *partner = &port->partner_oper;
 
 		__choose_matched(lacpdu, port);
-		// record the new parameter values for the partner operational
+		/* record the new values for the operational partner */
 		partner->port_number = ntohs(lacpdu->actor_port);
 		partner->port_priority = ntohs(lacpdu->actor_port_priority);
 		partner->system = lacpdu->actor_system;
@@ -506,10 +503,12 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
 		partner->key = ntohs(lacpdu->actor_key);
 		partner->port_state = lacpdu->actor_state;
 
-		// set actor_oper_port_state.defaulted to FALSE
+		/* set actor_oper_port_state.defaulted to FALSE */
 		port->actor_oper_port_state &= ~AD_STATE_DEFAULTED;
 
-		// set the partner sync. to on if the partner is sync. and the port is matched
+		/* switch on partner sync. if partner is synchronized,
+		 * and the port is matched
+		 */
 		if ((port->sm_vars & AD_PORT_MATCHED)
 		    && (lacpdu->actor_state & AD_STATE_SYNCHRONIZATION))
 			partner->port_state |= AD_STATE_SYNCHRONIZATION;
@@ -529,11 +528,8 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
 static void __record_default(struct port *port)
 {
 	if (port) {
-		// record the partner admin parameters
 		memcpy(&port->partner_oper, &port->partner_admin,
 		       sizeof(struct port_params));
-
-		// set actor_oper_port_state.defaulted to true
 		port->actor_oper_port_state |= AD_STATE_DEFAULTED;
 	}
 }
@@ -556,14 +552,17 @@ static void __update_selected(struct lacpdu *lacpdu, struct port *port)
 	if (lacpdu && port) {
 		const struct port_params *partner = &port->partner_oper;
 
-		// check if any parameter is different
-		if (ntohs(lacpdu->actor_port) != partner->port_number ||
-		    ntohs(lacpdu->actor_port_priority) != partner->port_priority ||
-		    MAC_ADDRESS_COMPARE(&lacpdu->actor_system, &partner->system) ||
-		    ntohs(lacpdu->actor_system_priority) != partner->system_priority ||
-		    ntohs(lacpdu->actor_key) != partner->key ||
-		    (lacpdu->actor_state & AD_STATE_AGGREGATION) != (partner->port_state & AD_STATE_AGGREGATION)) {
-			// update the state machine Selected variable
+		if (ntohs(lacpdu->actor_port) != partner->port_number
+		    || ntohs(lacpdu->actor_port_priority) !=
+							partner->port_priority
+		    || MAC_ADDRESS_COMPARE(&lacpdu->actor_system,
+							&partner->system)
+		    || ntohs(lacpdu->actor_system_priority) !=
+							partner->system_priority
+		    || ntohs(lacpdu->actor_key) != partner->key
+		    || (lacpdu->actor_state & AD_STATE_AGGREGATION) !=
+		    (partner->port_state & AD_STATE_AGGREGATION)) {
+			/* update the state machine Selected variable */
 			port->sm_vars &= ~AD_PORT_SELECTED;
 		}
 	}
@@ -587,7 +586,6 @@ static void __update_default_selected(struct port *port)
 		const struct port_params *admin = &port->partner_admin;
 		const struct port_params *oper = &port->partner_oper;
 
-		// check if any parameter is different
 		if (admin->port_number != oper->port_number ||
 		    admin->port_priority != oper->port_priority ||
 		    MAC_ADDRESS_COMPARE(&admin->system, &oper->system) ||
@@ -595,7 +593,7 @@ static void __update_default_selected(struct port *port)
 		    admin->key != oper->key ||
 		    (admin->port_state & AD_STATE_AGGREGATION)
 			!= (oper->port_state & AD_STATE_AGGREGATION)) {
-			// update the state machine Selected variable
+			/* update the state machine Selected variable */
 			port->sm_vars &= ~AD_PORT_SELECTED;
 		}
 	}
@@ -615,20 +613,24 @@ static void __update_default_selected(struct port *port)
  */
 static void __update_ntt(struct lacpdu *lacpdu, struct port *port)
 {
-	// validate lacpdu and port
 	if (lacpdu && port) {
-		// check if any parameter is different
-		if ((ntohs(lacpdu->partner_port) != port->actor_port_number) ||
-		    (ntohs(lacpdu->partner_port_priority) != port->actor_port_priority) ||
-		    MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) ||
-		    (ntohs(lacpdu->partner_system_priority) != port->actor_system_priority) ||
-		    (ntohs(lacpdu->partner_key) != port->actor_oper_port_key) ||
-		    ((lacpdu->partner_state & AD_STATE_LACP_ACTIVITY) != (port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY)) ||
-		    ((lacpdu->partner_state & AD_STATE_LACP_TIMEOUT) != (port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT)) ||
-		    ((lacpdu->partner_state & AD_STATE_SYNCHRONIZATION) != (port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION)) ||
-		    ((lacpdu->partner_state & AD_STATE_AGGREGATION) != (port->actor_oper_port_state & AD_STATE_AGGREGATION))
-		   ) {
-
+		if ((ntohs(lacpdu->partner_port) != port->actor_port_number)
+		    || (ntohs(lacpdu->partner_port_priority) !=
+						port->actor_port_priority)
+		    || MAC_ADDRESS_COMPARE(&(lacpdu->partner_system),
+						&(port->actor_system))
+		    || (ntohs(lacpdu->partner_system_priority) !=
+						port->actor_system_priority)
+		    || (ntohs(lacpdu->partner_key) != port->actor_oper_port_key)
+		    || ((lacpdu->partner_state & AD_STATE_LACP_ACTIVITY) !=
+			(port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY))
+		    || ((lacpdu->partner_state & AD_STATE_LACP_TIMEOUT) !=
+			(port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT))
+		    || ((lacpdu->partner_state & AD_STATE_SYNCHRONIZATION) !=
+		       (port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION))
+		    || ((lacpdu->partner_state & AD_STATE_AGGREGATION) !=
+		    (port->actor_oper_port_state & AD_STATE_AGGREGATION))) {
+			/* set port ntt */
 			port->ntt = true;
 		}
 	}
@@ -644,9 +646,7 @@ static void __update_ntt(struct lacpdu *lacpdu, struct port *port)
  */
 static void __attach_bond_to_agg(struct port *port)
 {
-	port = NULL; /* just to satisfy the compiler */
-	// This function does nothing since the parser/multiplexer of the receive
-	// and the parser/multiplexer of the aggregator are already combined
+	port = NULL;
 }
 
 /**
@@ -659,9 +659,7 @@ static void __attach_bond_to_agg(struct port *port)
  */
 static void __detach_bond_from_agg(struct port *port)
 {
-	port = NULL; /* just to satisfy the compiler */
-	// This function does nothing sience the parser/multiplexer of the receive
-	// and the parser/multiplexer of the aggregator are already combined
+	port = NULL;
 }
 
 /**
@@ -675,7 +673,9 @@ static int __agg_ports_are_ready(struct aggregator *aggregator)
 	int retval = 1;
 
 	if (aggregator) {
-		// scan all ports in this aggregator to verfy if they are all ready
+		/* scan all ports in this aggregator to verfy
+		 * if they are all ready
+		 */
 		for (port = aggregator->lag_ports;
 		     port;
 		     port = port->next_port_in_aggregator) {
@@ -737,7 +737,7 @@ static u32 __get_agg_bandwidth(struct aggregator *aggregator)
 			bandwidth = aggregator->num_of_ports * 10000;
 			break;
 		default:
-			bandwidth = 0; /*to silence the compiler ....*/
+			bandwidth = 0;
 		}
 	}
 	return bandwidth;
@@ -809,10 +809,7 @@ static inline void __update_lacpdu_from_port(struct port *port)
 	 */
 }
 
-//////////////////////////////////////////////////////////////////////////////////////
-// ================= main 802.3ad protocol code ======================================
-//////////////////////////////////////////////////////////////////////////////////////
-
+/* ================= main 802.3ad protocol code ================= */
 /**
  * ad_lacpdu_send - send out a lacpdu packet on a given port
  * @port: the port we're looking at
@@ -845,7 +842,7 @@ static int ad_lacpdu_send(struct port *port)
 	memcpy(lacpdu_header->hdr.h_source, slave->perm_hwaddr, ETH_ALEN);
 	lacpdu_header->hdr.h_proto = PKT_TYPE_LACPDU;
 
-	lacpdu_header->lacpdu = port->lacpdu; // struct copy
+	lacpdu_header->lacpdu = port->lacpdu;
 
 	dev_queue_xmit(skb);
 
@@ -886,7 +883,7 @@ static int ad_marker_send(struct port *port, struct bond_marker *marker)
 	memcpy(marker_header->hdr.h_source, slave->perm_hwaddr, ETH_ALEN);
 	marker_header->hdr.h_proto = PKT_TYPE_LACPDU;
 
-	marker_header->marker = *marker; // struct copy
+	marker_header->marker = *marker;
 
 	dev_queue_xmit(skb);
 
@@ -902,80 +899,100 @@ static void ad_mux_machine(struct port *port)
 {
 	mux_states_t last_state;
 
-	// keep current State Machine state to compare later if it was changed
 	last_state = port->sm_mux_state;
 
 	if (port->sm_vars & AD_PORT_BEGIN) {
-		port->sm_mux_state = AD_MUX_DETACHED;		 // next state
+		port->sm_mux_state = AD_MUX_DETACHED;
 	} else {
 		switch (port->sm_mux_state) {
 		case AD_MUX_DETACHED:
 			if ((port->sm_vars & AD_PORT_SELECTED)
 			    || (port->sm_vars & AD_PORT_STANDBY))
 				/* if SELECTED or STANDBY */
-				port->sm_mux_state = AD_MUX_WAITING; // next state
+				port->sm_mux_state = AD_MUX_WAITING;
 			break;
 		case AD_MUX_WAITING:
-			// if SELECTED == FALSE return to DETACH state
-			if (!(port->sm_vars & AD_PORT_SELECTED)) { // if UNSELECTED
+			/* if SELECTED == FALSE return to DETACH state */
+			if (!(port->sm_vars & AD_PORT_SELECTED)) {
 				port->sm_vars &= ~AD_PORT_READY_N;
-				// in order to withhold the Selection Logic to check all ports READY_N value
-				// every callback cycle to update ready variable, we check READY_N and update READY here
-				__set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
-				port->sm_mux_state = AD_MUX_DETACHED;	 // next state
+				/* in order to withhold the Selection Logic
+				 * to check all ports READY_N value at every
+				 * callback cycle to update ready variable,
+				 * we check READY_N and update READY here
+				 */
+				__set_agg_ports_ready(port->aggregator,
+				       __agg_ports_are_ready(port->aggregator));
+				port->sm_mux_state = AD_MUX_DETACHED;
 				break;
 			}
 
-			// check if the wait_while_timer expired
+			/* check if the wait_while_timer expired */
 			if (port->sm_mux_timer_counter
 			    && !(--port->sm_mux_timer_counter))
 				port->sm_vars |= AD_PORT_READY_N;
 
-			// in order to withhold the selection logic to check all ports READY_N value
-			// every callback cycle to update ready variable, we check READY_N and update READY here
-			__set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
-
-			// if the wait_while_timer expired, and the port is in READY state, move to ATTACHED state
+			/* in order to withhold the selection logic
+			 * to check all ports READY_N value at every
+			 * callback cycle to update ready variable,
+			 * we check READY_N and update READY here
+			 */
+			__set_agg_ports_ready(port->aggregator,
+				       __agg_ports_are_ready(port->aggregator));
+
+			/* if the wait_while_timer expired,  and the port
+			 * is in READY state, move to ATTACHED state
+			 */
 			if ((port->sm_vars & AD_PORT_READY)
 			    && !port->sm_mux_timer_counter)
-				port->sm_mux_state = AD_MUX_ATTACHED;	 // next state
+				port->sm_mux_state = AD_MUX_ATTACHED;
 			break;
 		case AD_MUX_ATTACHED:
-			// check also if agg_select_timer expired(so the edable port will take place only after this timer)
-			if ((port->sm_vars & AD_PORT_SELECTED) && (port->partner_oper.port_state & AD_STATE_SYNCHRONIZATION) && !__check_agg_selection_timer(port)) {
-				port->sm_mux_state = AD_MUX_COLLECTING_DISTRIBUTING;// next state
-			} else if (!(port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY)) {	  // if UNSELECTED or STANDBY
+			/* check also if agg_select_timer expired (so the
+			 * edable port will take place only after this timer)
+			 */
+			if ((port->sm_vars & AD_PORT_SELECTED) &&
+			    (port->partner_oper.port_state &
+			     AD_STATE_SYNCHRONIZATION) &&
+			    !__check_agg_selection_timer(port)) {
+				port->sm_mux_state =
+					AD_MUX_COLLECTING_DISTRIBUTING;
+			} else if (!(port->sm_vars & AD_PORT_SELECTED) ||
+				   (port->sm_vars & AD_PORT_STANDBY)) {
+				/* if UNSELECTED or STANDBY */
 				port->sm_vars &= ~AD_PORT_READY_N;
-				// in order to withhold the selection logic to check all ports READY_N value
-				// every callback cycle to update ready variable, we check READY_N and update READY here
-				__set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
-				port->sm_mux_state = AD_MUX_DETACHED;// next state
+				/* in order to withhold the Selection Logic
+				 * to check all ports READY_N value at every
+				 * callback cycle to update ready variable,
+				 * we check READY_N and update READY here
+				 */
+				__set_agg_ports_ready(port->aggregator,
+				       __agg_ports_are_ready(port->aggregator));
+				port->sm_mux_state = AD_MUX_DETACHED;
 			}
 			break;
 		case AD_MUX_COLLECTING_DISTRIBUTING:
-			if (!(port->sm_vars & AD_PORT_SELECTED) || (port->sm_vars & AD_PORT_STANDBY) ||
-			    !(port->partner_oper.port_state & AD_STATE_SYNCHRONIZATION)
-			   ) {
-				port->sm_mux_state = AD_MUX_ATTACHED;// next state
-
+			if (!(port->sm_vars & AD_PORT_SELECTED) ||
+			    (port->sm_vars & AD_PORT_STANDBY) ||
+			    !(port->partner_oper.port_state &
+			     AD_STATE_SYNCHRONIZATION)) {
+				port->sm_mux_state = AD_MUX_ATTACHED;
 			} else {
-				// if port state hasn't changed make
-				// sure that a collecting distributing
-				// port in an active aggregator is enabled
+				/* if port state hasn't changed make
+				 * sure that a collecting distributing
+				 * port in an active aggregator is enabled
+				 */
 				if (port->aggregator &&
 				    port->aggregator->is_active &&
-				    !__port_is_enabled(port)) {
-
+				    !__port_is_enabled(port))
 					__enable_port(port);
-				}
 			}
 			break;
-		default:    //to silence the compiler
+		default:
 			break;
 		}
 	}
 
-	// check if the state machine was changed
+	/* check if the state machine was changed */
 	if (port->sm_mux_state != last_state) {
 		pr_debug("Mux Machine: Port=%d, Last State=%d, Curr State=%d\n",
 			 port->actor_port_number, last_state,
@@ -983,14 +1000,16 @@ static void ad_mux_machine(struct port *port)
 		switch (port->sm_mux_state) {
 		case AD_MUX_DETACHED:
 			__detach_bond_from_agg(port);
-			port->actor_oper_port_state &= ~AD_STATE_SYNCHRONIZATION;
+			port->actor_oper_port_state &=
+					~AD_STATE_SYNCHRONIZATION;
 			ad_disable_collecting_distributing(port);
 			port->actor_oper_port_state &= ~AD_STATE_COLLECTING;
 			port->actor_oper_port_state &= ~AD_STATE_DISTRIBUTING;
 			port->ntt = true;
 			break;
 		case AD_MUX_WAITING:
-			port->sm_mux_timer_counter = __ad_timer_to_ticks(AD_WAIT_WHILE_TIMER, 0);
+			port->sm_mux_timer_counter =
+				__ad_timer_to_ticks(AD_WAIT_WHILE_TIMER, 0);
 			break;
 		case AD_MUX_ATTACHED:
 			__attach_bond_to_agg(port);
@@ -1006,7 +1025,7 @@ static void ad_mux_machine(struct port *port)
 			ad_enable_collecting_distributing(port);
 			port->ntt = true;
 			break;
-		default:    //to silence the compiler
+		default:
 			break;
 		}
 	}
@@ -1025,59 +1044,61 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
 {
 	rx_states_t last_state;
 
-	// keep current State Machine state to compare later if it was changed
 	last_state = port->sm_rx_state;
 
-	// check if state machine should change state
-	// first, check if port was reinitialized
+	/* check if state machine should change state
+	 first, check if port was reinitialized */
 	if (port->sm_vars & AD_PORT_BEGIN)
 		/* next state */
 		port->sm_rx_state = AD_RX_INITIALIZE;
-	// check if port is not enabled
+	/* check if port is not enabled */
 	else if (!(port->sm_vars & AD_PORT_BEGIN)
 		 && !port->is_enabled && !(port->sm_vars & AD_PORT_MOVED))
 		/* next state */
 		port->sm_rx_state = AD_RX_PORT_DISABLED;
-	// check if new lacpdu arrived
-	else if (lacpdu && ((port->sm_rx_state == AD_RX_EXPIRED) || (port->sm_rx_state == AD_RX_DEFAULTED) || (port->sm_rx_state == AD_RX_CURRENT))) {
-		port->sm_rx_timer_counter = 0; // zero timer
+	/* check if new lacpdu arrived */
+	else if (lacpdu && ((port->sm_rx_state == AD_RX_EXPIRED) ||
+		 (port->sm_rx_state == AD_RX_DEFAULTED) ||
+		 (port->sm_rx_state == AD_RX_CURRENT))) {
+		port->sm_rx_timer_counter = 0; /* zero timer */
 		port->sm_rx_state = AD_RX_CURRENT;
 	} else {
-		// if timer is on, and if it is expired
-		if (port->sm_rx_timer_counter && !(--port->sm_rx_timer_counter)) {
+		/* if timer is on, and if it is expired */
+		if (port->sm_rx_timer_counter &&
+		    !(--port->sm_rx_timer_counter)) {
 			switch (port->sm_rx_state) {
 			case AD_RX_EXPIRED:
-				port->sm_rx_state = AD_RX_DEFAULTED;		// next state
+				port->sm_rx_state = AD_RX_DEFAULTED;
 				break;
 			case AD_RX_CURRENT:
-				port->sm_rx_state = AD_RX_EXPIRED;	    // next state
+				port->sm_rx_state = AD_RX_EXPIRED;
 				break;
-			default:    //to silence the compiler
+			default:
 				break;
 			}
 		} else {
-			// if no lacpdu arrived and no timer is on
+			/* if no lacpdu arrived and no timer is on */
 			switch (port->sm_rx_state) {
 			case AD_RX_PORT_DISABLED:
 				if (port->sm_vars & AD_PORT_MOVED)
-					port->sm_rx_state = AD_RX_INITIALIZE;	    // next state
+					port->sm_rx_state = AD_RX_INITIALIZE;
 				else if (port->is_enabled
 					 && (port->sm_vars
 					     & AD_PORT_LACP_ENABLED))
-					port->sm_rx_state = AD_RX_EXPIRED;	// next state
+					port->sm_rx_state = AD_RX_EXPIRED;
 				else if (port->is_enabled
 					 && ((port->sm_vars
 					      & AD_PORT_LACP_ENABLED) == 0))
-					port->sm_rx_state = AD_RX_LACP_DISABLED;    // next state
+					port->sm_rx_state = AD_RX_LACP_DISABLED;
 				break;
-			default:    //to silence the compiler
+			default:
 				break;
 
 			}
 		}
 	}
 
-	// check if the State machine was changed or new lacpdu arrived
+	/* check if the State machine was changed or new lacpdu arrived */
 	if ((port->sm_rx_state != last_state) || (lacpdu)) {
 		pr_debug("Rx Machine: Port=%d, Last State=%d, Curr State=%d\n",
 			 port->actor_port_number, last_state,
@@ -1092,7 +1113,7 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
 			__record_default(port);
 			port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
 			port->sm_vars &= ~AD_PORT_MOVED;
-			port->sm_rx_state = AD_RX_PORT_DISABLED;	// next state
+			port->sm_rx_state = AD_RX_PORT_DISABLED;
 
 			/*- Fall Through -*/
 
@@ -1107,14 +1128,20 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
 			port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
 			break;
 		case AD_RX_EXPIRED:
-			//Reset of the Synchronization flag. (Standard 43.4.12)
-			//This reset cause to disable this port in the COLLECTING_DISTRIBUTING state of the
-			//mux machine in case of EXPIRED even if LINK_DOWN didn't arrive for the port.
-			port->partner_oper.port_state &= ~AD_STATE_SYNCHRONIZATION;
+			/* Reset of the Synchronization flag. (Standard 43.4.12)
+			 * This reset cause to disable this port in the
+			 * COLLECTING_DISTRIBUTING state of the mux machine
+			 * in case of EXPIRED even if LINK_DOWN didn't arrive
+			 * for the port.
+			 */
+			port->partner_oper.port_state &=
+						~AD_STATE_SYNCHRONIZATION;
 			port->sm_vars &= ~AD_PORT_MATCHED;
 			port->partner_oper.port_state |=
 				AD_STATE_LACP_ACTIVITY;
-			port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT));
+			port->sm_rx_timer_counter =
+				__ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER,
+						(u16)(AD_SHORT_TIMEOUT));
 			port->actor_oper_port_state |= AD_STATE_EXPIRED;
 			break;
 		case AD_RX_DEFAULTED:
@@ -1124,28 +1151,38 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
 			port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
 			break;
 		case AD_RX_CURRENT:
-			// detect loopback situation
-			if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) {
-				// INFO_RECEIVED_LOOPBACK_FRAMES
-				pr_err("%s: An illegal loopback occurred on adapter (%s).\n"
-				       "Check the configuration to verify that all adapters are connected to 802.3ad compliant switch ports\n",
-				       port->slave->dev->master->name, port->slave->dev->name);
+			/* detect loopback situation */
+			if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system),
+			    &(port->actor_system))) {
+				/* INFO_RECEIVED_LOOPBACK_FRAMES */
+				pr_err("%s: An illegal loopback occurred on "
+					"adapter (%s).\nCheck the configuration"
+					" to verify that all adapters are "
+					"connected to 802.3ad compliant "
+					"switch ports\n",
+						port->slave->dev->master->name,
+						port->slave->dev->name);
 				return;
 			}
 			__update_selected(lacpdu, port);
 			__update_ntt(lacpdu, port);
 			__record_pdu(lacpdu, port);
-			port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT));
+			port->sm_rx_timer_counter =
+				__ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER,
+					(u16)(port->actor_oper_port_state
+					& AD_STATE_LACP_TIMEOUT));
 			port->actor_oper_port_state &= ~AD_STATE_EXPIRED;
-			// verify that if the aggregator is enabled, the port is enabled too.
-			//(because if the link goes down for a short time, the 802.3ad will not
-			// catch it, and the port will continue to be disabled)
+			/* verify that if the aggregator is enabled,
+			 * the port is enabled too. (because if the link
+			 * goes down for a short time, the 802.3ad will not
+			 *  catch it, and the port will continue to be disabled)
+			 */
 			if (port->aggregator
 			    && port->aggregator->is_active
 			    && !__port_is_enabled(port))
 				__enable_port(port);
 			break;
-		default:    //to silence the compiler
+		default:
 			break;
 		}
 	}
@@ -1158,9 +1195,11 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
  */
 static void ad_tx_machine(struct port *port)
 {
-	// check if tx timer expired, to verify that we do not send more than 3 packets per second
+	/* check if tx timer expired, to verify that we do not
+	 * send more than 3 packets per second
+	 */
 	if (port->sm_tx_timer_counter && !(--port->sm_tx_timer_counter)) {
-		// check if there is something to send
+		/* check if there is something to send */
 		if (port->ntt && (port->sm_vars & AD_PORT_LACP_ENABLED)) {
 			__update_lacpdu_from_port(port);
 
@@ -1168,14 +1207,17 @@ static void ad_tx_machine(struct port *port)
 				pr_debug("Sent LACPDU on port %d\n",
 					 port->actor_port_number);
 
-				/* mark ntt as false, so it will not be sent again until
-				   demanded */
+				/* mark ntt as false, so it will not be
+				 * sent again until demanded
+				 */
 				port->ntt = false;
 			}
 		}
-		// restart tx timer(to verify that we will not exceed AD_MAX_TX_IN_SECOND
+		/* restart tx timer(to verify that we will not
+		 * exceed AD_MAX_TX_IN_SECOND
+		 */
 		port->sm_tx_timer_counter =
-			ad_ticks_per_sec/AD_MAX_TX_IN_SECOND;
+				ad_ticks_per_sec/AD_MAX_TX_IN_SECOND;
 	}
 }
 
@@ -1189,76 +1231,92 @@ static void ad_periodic_machine(struct port *port)
 {
 	periodic_states_t last_state;
 
-	// keep current state machine state to compare later if it was changed
+	/* keep current state machine state to compare
+	 * later if it was changed
+	 */
 	last_state = port->sm_periodic_state;
 
-	// check if port was reinitialized
-	if (((port->sm_vars & AD_PORT_BEGIN) || !(port->sm_vars & AD_PORT_LACP_ENABLED) || !port->is_enabled) ||
-	    (!(port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY) && !(port->partner_oper.port_state & AD_STATE_LACP_ACTIVITY))
-	   ) {
-		port->sm_periodic_state = AD_NO_PERIODIC;	     // next state
+	/* check if port was reinitialized */
+	if (((port->sm_vars & AD_PORT_BEGIN) ||
+	    !(port->sm_vars & AD_PORT_LACP_ENABLED) ||
+	    !port->is_enabled) ||
+	    (!(port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY) &&
+	     !(port->partner_oper.port_state & AD_STATE_LACP_ACTIVITY))) {
+		port->sm_periodic_state = AD_NO_PERIODIC; /* next state */
 	}
-	// check if state machine should change state
+	/* check if state machine should change state */
 	else if (port->sm_periodic_timer_counter) {
-		// check if periodic state machine expired
+		/* check if periodic state machine expired */
 		if (!(--port->sm_periodic_timer_counter)) {
-			// if expired then do tx
-			port->sm_periodic_state = AD_PERIODIC_TX;    // next state
+			/* if expired then do tx, next state */
+			port->sm_periodic_state = AD_PERIODIC_TX;
 		} else {
-			// If not expired, check if there is some new timeout parameter from the partner state
+			/* If not expired, check if there is some
+			 * new timeout parameter from the partner state
+			 */
 			switch (port->sm_periodic_state) {
 			case AD_FAST_PERIODIC:
 				if (!(port->partner_oper.port_state
 				      & AD_STATE_LACP_TIMEOUT))
-					port->sm_periodic_state = AD_SLOW_PERIODIC;  // next state
+					port->sm_periodic_state =
+							AD_SLOW_PERIODIC;
 				break;
 			case AD_SLOW_PERIODIC:
-				if ((port->partner_oper.port_state & AD_STATE_LACP_TIMEOUT)) {
-					// stop current timer
+				if ((port->partner_oper.port_state &
+				     AD_STATE_LACP_TIMEOUT)) {
+					/* stop current timer */
 					port->sm_periodic_timer_counter = 0;
-					port->sm_periodic_state = AD_PERIODIC_TX;	 // next state
+					port->sm_periodic_state =
+							 AD_PERIODIC_TX;
 				}
 				break;
-			default:    //to silence the compiler
+			default:
 				break;
 			}
 		}
 	} else {
 		switch (port->sm_periodic_state) {
 		case AD_NO_PERIODIC:
-			port->sm_periodic_state = AD_FAST_PERIODIC;	 // next state
+			port->sm_periodic_state = AD_FAST_PERIODIC;
 			break;
 		case AD_PERIODIC_TX:
 			if (!(port->partner_oper.port_state
 			      & AD_STATE_LACP_TIMEOUT))
-				port->sm_periodic_state = AD_SLOW_PERIODIC;  // next state
+				port->sm_periodic_state = AD_SLOW_PERIODIC;
 			else
-				port->sm_periodic_state = AD_FAST_PERIODIC;  // next state
+				port->sm_periodic_state = AD_FAST_PERIODIC;
 			break;
-		default:    //to silence the compiler
+		default:
 			break;
 		}
 	}
 
-	// check if the state machine was changed
+	/* check if the state machine was changed */
 	if (port->sm_periodic_state != last_state) {
-		pr_debug("Periodic Machine: Port=%d, Last State=%d, Curr State=%d\n",
+		pr_debug("Periodic Machine: Port=%d, "
+			 "Last State=%d, Curr State=%d\n",
 			 port->actor_port_number, last_state,
 			 port->sm_periodic_state);
 		switch (port->sm_periodic_state) {
 		case AD_NO_PERIODIC:
-			port->sm_periodic_timer_counter = 0;	   // zero timer
+			port->sm_periodic_timer_counter = 0;
 			break;
 		case AD_FAST_PERIODIC:
-			port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_FAST_PERIODIC_TIME))-1; // decrement 1 tick we lost in the PERIODIC_TX cycle
+			/* decrement 1 tick we lost in PERIODIC_TX cycle */
+			port->sm_periodic_timer_counter =
+					__ad_timer_to_ticks(AD_PERIODIC_TIMER,
+						(u16)(AD_FAST_PERIODIC_TIME))-1;
 			break;
 		case AD_SLOW_PERIODIC:
-			port->sm_periodic_timer_counter = __ad_timer_to_ticks(AD_PERIODIC_TIMER, (u16)(AD_SLOW_PERIODIC_TIME))-1; // decrement 1 tick we lost in the PERIODIC_TX cycle
+			/* decrement 1 tick we lost in PERIODIC_TX cycle */
+			port->sm_periodic_timer_counter =
+					__ad_timer_to_ticks(AD_PERIODIC_TIMER,
+						(u16)(AD_SLOW_PERIODIC_TIME))-1;
 			break;
 		case AD_PERIODIC_TX:
 			port->ntt = true;
 			break;
-		default:    //to silence the compiler
+		default:
 			break;
 		}
 	}
@@ -1274,32 +1332,38 @@ static void ad_periodic_machine(struct port *port)
  */
 static void ad_port_selection_logic(struct port *port)
 {
-	struct aggregator *aggregator, *free_aggregator = NULL, *temp_aggregator;
+	struct aggregator *aggregator, *temp_aggregator;
+	struct aggregator *free_aggregator = NULL;
 	struct port *last_port = NULL, *curr_port;
 	int found = 0;
 
-	// if the port is already Selected, do nothing
+	/* if the port is already Selected, do nothing */
 	if (port->sm_vars & AD_PORT_SELECTED)
 		return;
 
-	// if the port is connected to other aggregator, detach it
+	/* if the port is connected to other aggregator, detach it */
 	if (port->aggregator) {
-		// detach the port from its former aggregator
+		/* detach the port from its former aggregator */
 		temp_aggregator = port->aggregator;
 		for (curr_port = temp_aggregator->lag_ports; curr_port;
 		     last_port = curr_port,
 			     curr_port = curr_port->next_port_in_aggregator) {
 			if (curr_port == port) {
 				temp_aggregator->num_of_ports--;
-				if (!last_port) {// if it is the first port attached to the aggregator
+				if (!last_port) {
+					/* if it is the first port attached
+					   to the aggregator */
 					temp_aggregator->lag_ports =
 						port->next_port_in_aggregator;
-				} else {// not the first port attached to the aggregator
+				} else {
+					/* not the first port attached
+					   to the aggregator */
 					last_port->next_port_in_aggregator =
 						port->next_port_in_aggregator;
 				}
 
-				// clear the port's relations to this aggregator
+				/* clear the port's relations
+				   to this aggregator */
 				port->aggregator = NULL;
 				port->next_port_in_aggregator = NULL;
 				port->actor_port_aggregator_identifier = 0;
@@ -1307,41 +1371,51 @@ static void ad_port_selection_logic(struct port *port)
 				pr_debug("Port %d left LAG %d\n",
 					 port->actor_port_number,
 					 temp_aggregator->aggregator_identifier);
-				// if the aggregator is empty, clear its parameters, and set it ready to be attached
+				/* if the aggregator is empty,
+				 * clear its parameters, and set it
+				 * ready to be attached
+				 */
 				if (!temp_aggregator->lag_ports)
 					ad_clear_agg(temp_aggregator);
 				break;
 			}
 		}
-		if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list
-			pr_warning("%s: Warning: Port %d (on %s) was related to aggregator %d but was not on its port list\n",
-				   port->slave->dev->master->name,
-				   port->actor_port_number,
-				   port->slave->dev->name,
-				   port->aggregator->aggregator_identifier);
+		if (!curr_port) {
+			/* meaning: the port was related to an aggregator
+			 * but was not on the aggregator port list.
+			 */
+			pr_warning("%s: Warning: Port %d (on %s) was related "
+				   "to aggregator %d but was not on its port "
+				   "list\n", port->slave->dev->master->name,
+				    port->actor_port_number,
+				    port->slave->dev->name,
+				    port->aggregator->aggregator_identifier);
 		}
 	}
-	// search on all aggregators for a suitable aggregator for this port
+
+	/* search on all aggregators for a suitable aggregator for this port */
 	for (aggregator = __get_first_agg(port); aggregator;
 	     aggregator = __get_next_agg(aggregator)) {
 
-		// keep a free aggregator for later use(if needed)
+		/*/ keep a free aggregator for later use(if needed) */
 		if (!aggregator->lag_ports) {
 			if (!free_aggregator)
 				free_aggregator = aggregator;
 			continue;
 		}
-		// check if current aggregator suits us
-		if (((aggregator->actor_oper_aggregator_key == port->actor_oper_port_key) && // if all parameters match AND
-		     !MAC_ADDRESS_COMPARE(&(aggregator->partner_system), &(port->partner_oper.system)) &&
-		     (aggregator->partner_system_priority == port->partner_oper.system_priority) &&
-		     (aggregator->partner_oper_aggregator_key == port->partner_oper.key)
-		    ) &&
-		    ((MAC_ADDRESS_COMPARE(&(port->partner_oper.system), &(null_mac_addr)) && // partner answers
-		      !aggregator->is_individual)  // but is not individual OR
-		    )
-		   ) {
-			// attach to the founded aggregator
+		/* check if current aggregator suits us */
+		if (((aggregator->actor_oper_aggregator_key ==
+					      port->actor_oper_port_key)
+		      && !MAC_ADDRESS_COMPARE(&(aggregator->partner_system),
+						&(port->partner_oper.system))
+		      && (aggregator->partner_system_priority ==
+					port->partner_oper.system_priority)
+		      && (aggregator->partner_oper_aggregator_key ==
+						port->partner_oper.key))
+		    && ((MAC_ADDRESS_COMPARE(&(port->partner_oper.system),
+						&(null_mac_addr))
+		      && !aggregator->is_individual))) {
+			/* attach to the founded aggregator */
 			port->aggregator = aggregator;
 			port->actor_port_aggregator_identifier =
 				port->aggregator->aggregator_identifier;
@@ -1352,56 +1426,63 @@ static void ad_port_selection_logic(struct port *port)
 				 port->actor_port_number,
 				 port->aggregator->aggregator_identifier);
 
-			// mark this port as selected
+			/* mark this port as selected */
 			port->sm_vars |= AD_PORT_SELECTED;
 			found = 1;
 			break;
 		}
 	}
 
-	// the port couldn't find an aggregator - attach it to a new aggregator
+	/* the port couldn't find an aggregator,
+	   attach it to a new aggregator */
 	if (!found) {
 		if (free_aggregator) {
-			// assign port a new aggregator
+			/* assign port a new aggregator */
 			port->aggregator = free_aggregator;
 			port->actor_port_aggregator_identifier =
 				port->aggregator->aggregator_identifier;
 
-			// update the new aggregator's parameters
-			// if port was responsed from the end-user
+			/* update the new aggregator's parameters
+			   if port was responsed from the end-user */
 			if (port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)
 				/* if port is full duplex */
 				port->aggregator->is_individual = false;
 			else
 				port->aggregator->is_individual = true;
 
-			port->aggregator->actor_admin_aggregator_key = port->actor_admin_port_key;
-			port->aggregator->actor_oper_aggregator_key = port->actor_oper_port_key;
+			port->aggregator->actor_admin_aggregator_key =
+						port->actor_admin_port_key;
+			port->aggregator->actor_oper_aggregator_key =
+						port->actor_oper_port_key;
 			port->aggregator->partner_system =
-				port->partner_oper.system;
+						port->partner_oper.system;
 			port->aggregator->partner_system_priority =
-				port->partner_oper.system_priority;
-			port->aggregator->partner_oper_aggregator_key = port->partner_oper.key;
+					port->partner_oper.system_priority;
+			port->aggregator->partner_oper_aggregator_key =
+						port->partner_oper.key;
 			port->aggregator->receive_state = 1;
 			port->aggregator->transmit_state = 1;
 			port->aggregator->lag_ports = port;
 			port->aggregator->num_of_ports++;
 
-			// mark this port as selected
+			/* mark this port as selected */
 			port->sm_vars |= AD_PORT_SELECTED;
 
 			pr_debug("Port %d joined LAG %d(new LAG)\n",
 				 port->actor_port_number,
 				 port->aggregator->aggregator_identifier);
 		} else {
-			pr_err("%s: Port %d (on %s) did not find a suitable aggregator\n",
-			       port->slave->dev->master->name,
+			pr_err("%s: Port %d (on %s) did not find a suitable "
+			       "aggregator\n", port->slave->dev->master->name,
 			       port->actor_port_number, port->slave->dev->name);
 		}
 	}
-	// if all aggregator's ports are READY_N == TRUE, set ready=TRUE in all aggregator's ports
-	// else set ready=FALSE in all aggregator's ports
-	__set_agg_ports_ready(port->aggregator, __agg_ports_are_ready(port->aggregator));
+	/* if all aggregator's ports are READY_N == TRUE,
+	 * set ready=TRUE in all aggregator's ports
+	 * else set ready=FALSE in all aggregator's ports
+	 */
+	__set_agg_ports_ready(port->aggregator,
+				__agg_ports_are_ready(port->aggregator));
 
 	aggregator = __get_first_agg(port);
 	ad_agg_selection_logic(aggregator);
@@ -1556,7 +1637,7 @@ static void ad_agg_selection_logic(struct aggregator *agg)
 		active->is_active = 1;
 	}
 
-	// if there is new best aggregator, activate it
+	/* if there is new best aggregator, activate it */
 	if (best) {
 		pr_debug("best Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
 			 best->aggregator_identifier, best->num_of_ports,
@@ -1577,9 +1658,10 @@ static void ad_agg_selection_logic(struct aggregator *agg)
 				 agg->is_individual, agg->is_active);
 		}
 
-		// check if any partner replys
+		/* check if any partner replys */
 		if (best->is_individual) {
-			pr_warning("%s: Warning: No 802.3ad response from the link partner for any adapters in the bond\n",
+			pr_warning("%s: Warning: No 802.3ad response from the "
+				  "link partner for any adapters in the bond\n",
 				   best->slave ? best->slave->dev->master->name : "NULL");
 		}
 
@@ -1592,7 +1674,8 @@ static void ad_agg_selection_logic(struct aggregator *agg)
 			 best->partner_oper_aggregator_key,
 			 best->is_individual, best->is_active);
 
-		// disable the ports that were related to the former active_aggregator
+		/* disable the ports that were related to
+		   the former active_aggregator */
 		if (active) {
 			for (port = active->lag_ports; port;
 			     port = port->next_port_in_aggregator) {
@@ -1701,8 +1784,10 @@ static void ad_initialize_port(struct port *port, int lacp_fast)
 		port->ntt = false;
 		port->actor_admin_port_key = 1;
 		port->actor_oper_port_key  = 1;
-		port->actor_admin_port_state = AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
-		port->actor_oper_port_state  = AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
+		port->actor_admin_port_state =
+				AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
+		port->actor_oper_port_state  =
+				AD_STATE_AGGREGATION | AD_STATE_LACP_ACTIVITY;
 
 		if (lacp_fast)
 			port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT;
@@ -1711,7 +1796,7 @@ static void ad_initialize_port(struct port *port, int lacp_fast)
 		memcpy(&port->partner_oper, &tmpl, sizeof(tmpl));
 
 		port->is_enabled = true;
-		// ****** private parameters ******
+		/* ****** private parameters ****** */
 		port->sm_vars = 0x3;
 		port->sm_rx_state = 0;
 		port->sm_rx_timer_counter = 0;
@@ -1753,7 +1838,9 @@ static void ad_enable_collecting_distributing(struct port *port)
  */
 static void ad_disable_collecting_distributing(struct port *port)
 {
-	if (port->aggregator && MAC_ADDRESS_COMPARE(&(port->aggregator->partner_system), &(null_mac_addr))) {
+	if (port->aggregator &&
+	    MAC_ADDRESS_COMPARE(&(port->aggregator->partner_system),
+	     &(null_mac_addr))) {
 		pr_debug("Disabling port %d(LAG %d)\n",
 			 port->actor_port_number,
 			 port->aggregator->aggregator_identifier);
@@ -1775,15 +1862,16 @@ static void ad_marker_info_send(struct port *port)
 	struct bond_marker marker;
 	u16 index;
 
-	// fill the marker PDU with the appropriate values
+	/* fill the marker PDU with the appropriate values */
 	marker.subtype = 0x02;
 	marker.version_number = 0x01;
 	marker.tlv_type = AD_MARKER_INFORMATION_SUBTYPE;
 	marker.marker_length = 0x16;
-	// convert requester_port to Big Endian
-	marker.requester_port = (((port->actor_port_number & 0xFF) << 8) |((u16)(port->actor_port_number & 0xFF00) >> 8));
+	/* convert requester_port to Big Endian */
+	marker.requester_port = (((port->actor_port_number & 0xFF) << 8) |
+				((u16)(port->actor_port_number & 0xFF00) >> 8));
 	marker.requester_system = port->actor_system;
-	// convert requester_port(u32) to Big Endian
+	/* convert requester_port(u32) to Big Endian */
 	marker.requester_transaction_id =
 		(((++port->transaction_id & 0xFF) << 24)
 		 | ((port->transaction_id & 0xFF00) << 8)
@@ -1795,7 +1883,7 @@ static void ad_marker_info_send(struct port *port)
 	for (index = 0; index < 90; index++)
 		marker.reserved_90[index] = 0;
 
-	// send the marker information
+	/* send the marker information */
 	if (ad_marker_send(port, &marker) >= 0) {
 		pr_debug("Sent Marker Information on port %d\n",
 			 port->actor_port_number);
@@ -1814,12 +1902,13 @@ static void ad_marker_info_received(struct bond_marker *marker_info,
 {
 	struct bond_marker marker;
 
-	// copy the received marker data to the response marker
-	//marker = *marker_info;
+	/* copy the received marker data to the response marker
+	 * marker = *marker_info;
+	 */
 	memcpy(&marker, marker_info, sizeof(struct bond_marker));
-	// change the marker subtype to marker response
+	/* change the marker subtype to marker response */
 	marker.tlv_type = AD_MARKER_RESPONSE_SUBTYPE;
-	// send the marker response
+	/* send the marker response */
 
 	if (ad_marker_send(port, &marker) >= 0) {
 		pr_debug("Sent Marker Response on port %d\n",
@@ -1839,16 +1928,13 @@ static void ad_marker_info_received(struct bond_marker *marker_info,
 static void ad_marker_response_received(struct bond_marker *marker,
 	struct port *port)
 {
-	marker = NULL; /* just to satisfy the compiler */
-	port = NULL;  /* just to satisfy the compiler */
-	// DO NOTHING, SINCE WE DECIDED NOT TO IMPLEMENT THIS FEATURE FOR NOW
+	marker = NULL;
+	port = NULL;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////
-// ================= AD exported functions to the main bonding code ==================
-//////////////////////////////////////////////////////////////////////////////////////
+/* ============= AD exported functions to the main bonding code ============ */
 
-// Check aggregators status in team every T seconds
+/* Check aggregators status in team every T seconds */
 #define AD_AGGREGATOR_SELECTION_TIMER  8
 
 /*
@@ -1876,7 +1962,7 @@ static u16 aggregator_identifier;
  */
 void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast)
 {
-	// check that the bond is not initialized yet
+	/* check that the bond is not initialized yet */
 	if (MAC_ADDRESS_COMPARE(&(BOND_AD_INFO(bond).system.sys_mac_addr),
 				bond->dev->dev_addr)) {
 
@@ -1884,9 +1970,12 @@ void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fas
 
 		BOND_AD_INFO(bond).lacp_fast = lacp_fast;
 		BOND_AD_INFO(bond).system.sys_priority = 0xFFFF;
-		BOND_AD_INFO(bond).system.sys_mac_addr = *((struct mac_addr *)bond->dev->dev_addr);
+		BOND_AD_INFO(bond).system.sys_mac_addr =
+				      *((struct mac_addr *)bond->dev->dev_addr);
 
-		// initialize how many times this module is called in one second(should be about every 100ms)
+		/* initialize how many times this module is
+		 * called in one second(should be about every 100ms)
+		 */
 		ad_ticks_per_sec = tick_resolution;
 
 		bond_3ad_initiate_agg_selection(bond,
@@ -1914,31 +2003,37 @@ int bond_3ad_bind_slave(struct slave *slave)
 		return -1;
 	}
 
-	//check that the slave has not been initialized yet.
+	/* check that the slave has not been initialized yet. */
 	if (SLAVE_AD_INFO(slave).port.slave != slave) {
 
-		// port initialization
+		/* port initialization */
 		port = &(SLAVE_AD_INFO(slave).port);
 
 		ad_initialize_port(port, BOND_AD_INFO(bond).lacp_fast);
 
 		port->slave = slave;
 		port->actor_port_number = SLAVE_AD_INFO(slave).id;
-		// key is determined according to the link speed, duplex and user key(which is yet not supported)
-		//              ------------------------------------------------------------
-		// Port key :   | User key                       |      Speed       |Duplex|
-		//              ------------------------------------------------------------
-		//              16                               6               1 0
-		port->actor_admin_port_key = 0;	// initialize this parameter
+		/* key is determined according to the link speed,
+		 * duplex and user key(which is yet not supported)
+		 * Port key:
+		 * ------------------------------------------------------------
+		 * | User key                       |      Speed       |Duplex|
+		 * ------------------------------------------------------------
+		 * 16                               6                  1      0
+		 */
+		port->actor_admin_port_key = 0;	/* initialize this parameter */
 		port->actor_admin_port_key |= __get_duplex(port);
 		port->actor_admin_port_key |= (__get_link_speed(port) << 1);
 		port->actor_oper_port_key = port->actor_admin_port_key;
-		// if the port is not full duplex, then the port should be not lacp Enabled
+		/* if the port is not full duplex,
+		 * then the port should be not lacp Enabled
+		 */
 		if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS))
 			port->sm_vars &= ~AD_PORT_LACP_ENABLED;
-		// actor system is the bond's system
+		/* actor system is the bond's system */
 		port->actor_system = BOND_AD_INFO(bond).system.sys_mac_addr;
-		// tx timer(to verify that no more than MAX_TX_IN_SECOND lacpdu's are sent in one second)
+		/* tx timer (to verify that no more
+		   than MAX_TX_IN_SECOND lacpdu's are sent in one second) */
 		port->sm_tx_timer_counter = ad_ticks_per_sec/AD_MAX_TX_IN_SECOND;
 		port->aggregator = NULL;
 		port->next_port_in_aggregator = NULL;
@@ -1947,12 +2042,13 @@ int bond_3ad_bind_slave(struct slave *slave)
 		__initialize_port_locks(port);
 
 
-		// aggregator initialization
+		/* aggregator initialization */
 		aggregator = &(SLAVE_AD_INFO(slave).aggregator);
 
 		ad_initialize_agg(aggregator);
 
-		aggregator->aggregator_mac_address = *((struct mac_addr *)bond->dev->dev_addr);
+		aggregator->aggregator_mac_address =
+				      *((struct mac_addr *)bond->dev->dev_addr);
 		aggregator->aggregator_identifier = (++aggregator_identifier);
 		aggregator->slave = slave;
 		aggregator->is_active = 0;
@@ -1976,16 +2072,17 @@ void bond_3ad_unbind_slave(struct slave *slave)
 	struct aggregator *aggregator, *new_aggregator, *temp_aggregator;
 	int select_new_active_agg = 0;
 
-	// find the aggregator related to this slave
+	/* find the aggregator related to this slave */
 	aggregator = &(SLAVE_AD_INFO(slave).aggregator);
 
-	// find the port related to this slave
+	/* find the port related to this slave */
 	port = &(SLAVE_AD_INFO(slave).port);
 
-	// if slave is null, the whole port is not initialized
+	/* if slave is null, the whole port is not initialized */
 	if (!port->slave) {
-		pr_warning("Warning: %s: Trying to unbind an uninitialized port on %s\n",
-			   slave->dev->master->name, slave->dev->name);
+		pr_warning("Warning: %s: Trying to unbind an uninitialized "
+			   "port on %s\n", slave->dev->master->name,
+			   slave->dev->name);
 		return;
 	}
 
@@ -1997,99 +2094,135 @@ void bond_3ad_unbind_slave(struct slave *slave)
 	__update_lacpdu_from_port(port);
 	ad_lacpdu_send(port);
 
-	// check if this aggregator is occupied
+	/* check if this aggregator is occupied */
 	if (aggregator->lag_ports) {
-		// check if there are other ports related to this aggregator except
-		// the port related to this slave(thats ensure us that there is a
-		// reason to search for new aggregator, and that we will find one
-		if ((aggregator->lag_ports != port) || (aggregator->lag_ports->next_port_in_aggregator)) {
-			// find new aggregator for the related port(s)
+		/* check if there are other ports related to this aggregator
+		 * except the port related to this slave (thats ensure us that
+		 * there is a reason to search for new aggregator, and that we
+		 * will find one
+		 */
+		if ((aggregator->lag_ports != port) ||
+		    (aggregator->lag_ports->next_port_in_aggregator)) {
+			/* find new aggregator for the related port(s) */
 			new_aggregator = __get_first_agg(port);
-			for (; new_aggregator; new_aggregator = __get_next_agg(new_aggregator)) {
-				// if the new aggregator is empty, or it is connected to our port only
+			for (; new_aggregator;
+			     new_aggregator = __get_next_agg(new_aggregator)) {
+				/* if the new aggregator is empty,
+				   or it is connected to our port only */
 				if (!new_aggregator->lag_ports
 				    || ((new_aggregator->lag_ports == port)
 					&& !new_aggregator->lag_ports->next_port_in_aggregator))
 					break;
 			}
-			// if new aggregator found, copy the aggregator's parameters
-			// and connect the related lag_ports to the new aggregator
-			if ((new_aggregator) && ((!new_aggregator->lag_ports) || ((new_aggregator->lag_ports == port) && !new_aggregator->lag_ports->next_port_in_aggregator))) {
-				pr_debug("Some port(s) related to LAG %d - replaceing with LAG %d\n",
+			/* if new aggregator found, copy the aggregator's
+			 * parameters and connect the related lag_ports to the
+			 * new aggregator
+			 */
+			if ((new_aggregator) &&
+			    ((!new_aggregator->lag_ports) ||
+			     ((new_aggregator->lag_ports == port) &&
+			      !new_aggregator->lag_ports->next_port_in_aggregator))) {
+				pr_debug("Some port(s) related to LAG %d - "
+					 "replaceing with LAG %d\n",
 					 aggregator->aggregator_identifier,
 					 new_aggregator->aggregator_identifier);
 
-				if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) {
-					pr_info("%s: Removing an active aggregator\n",
+				if ((new_aggregator->lag_ports == port) &&
+				     new_aggregator->is_active) {
+					pr_info("%s: Removing an active "
+						"aggregator\n",
 						aggregator->slave->dev->master->name);
-					// select new active aggregator
+					/* select new active aggregator */
 					 select_new_active_agg = 1;
 				}
 
-				new_aggregator->is_individual = aggregator->is_individual;
-				new_aggregator->actor_admin_aggregator_key = aggregator->actor_admin_aggregator_key;
-				new_aggregator->actor_oper_aggregator_key = aggregator->actor_oper_aggregator_key;
-				new_aggregator->partner_system = aggregator->partner_system;
-				new_aggregator->partner_system_priority = aggregator->partner_system_priority;
-				new_aggregator->partner_oper_aggregator_key = aggregator->partner_oper_aggregator_key;
-				new_aggregator->receive_state = aggregator->receive_state;
-				new_aggregator->transmit_state = aggregator->transmit_state;
-				new_aggregator->lag_ports = aggregator->lag_ports;
-				new_aggregator->is_active = aggregator->is_active;
-				new_aggregator->num_of_ports = aggregator->num_of_ports;
-
-				// update the information that is written on the ports about the aggregator
-				for (temp_port = aggregator->lag_ports; temp_port;
-				     temp_port = temp_port->next_port_in_aggregator) {
+				new_aggregator->is_individual =
+						      aggregator->is_individual;
+				new_aggregator->actor_admin_aggregator_key =
+					 aggregator->actor_admin_aggregator_key;
+				new_aggregator->actor_oper_aggregator_key =
+					  aggregator->actor_oper_aggregator_key;
+				new_aggregator->partner_system =
+						     aggregator->partner_system;
+				new_aggregator->partner_system_priority =
+					    aggregator->partner_system_priority;
+				new_aggregator->partner_oper_aggregator_key =
+					aggregator->partner_oper_aggregator_key;
+				new_aggregator->receive_state =
+						      aggregator->receive_state;
+				new_aggregator->transmit_state =
+						     aggregator->transmit_state;
+				new_aggregator->lag_ports =
+							  aggregator->lag_ports;
+				new_aggregator->is_active =
+							  aggregator->is_active;
+				new_aggregator->num_of_ports =
+						       aggregator->num_of_ports;
+
+				/* update the information that is written on
+				 * the ports about the aggregator
+				 */
+				for (temp_port = aggregator->lag_ports;
+				     temp_port; temp_port = temp_port->next_port_in_aggregator) {
 					temp_port->aggregator = new_aggregator;
 					temp_port->actor_port_aggregator_identifier = new_aggregator->aggregator_identifier;
 				}
 
-				// clear the aggregator
+				/* clear the aggregator */
 				ad_clear_agg(aggregator);
 
 				if (select_new_active_agg)
 					ad_agg_selection_logic(__get_first_agg(port));
 			} else {
-				pr_warning("%s: Warning: unbinding aggregator, and could not find a new aggregator for its ports\n",
+				pr_warning("%s: Warning: unbinding aggregator, "
+					   "and could not find a new aggregator"
+					   " for its ports\n",
 					   slave->dev->master->name);
 			}
-		} else { // in case that the only port related to this aggregator is the one we want to remove
+		} else {
+			 /* in case that the only port related to this
+			  * aggregator is the one we want to remove
+			  */
 			select_new_active_agg = aggregator->is_active;
-			// clear the aggregator
+			/* clear the aggregator */
 			ad_clear_agg(aggregator);
 			if (select_new_active_agg) {
 				pr_info("%s: Removing an active aggregator\n",
 					slave->dev->master->name);
-				// select new active aggregator
+				/* select new active aggregator */
 				ad_agg_selection_logic(__get_first_agg(port));
 			}
 		}
 	}
 
 	pr_debug("Unbinding port %d\n", port->actor_port_number);
-	// find the aggregator that this port is connected to
+	/* find the aggregator that this port is connected to */
 	temp_aggregator = __get_first_agg(port);
-	for (; temp_aggregator; temp_aggregator = __get_next_agg(temp_aggregator)) {
+	for (; temp_aggregator;
+	     temp_aggregator = __get_next_agg(temp_aggregator)) {
 		prev_port = NULL;
-		// search the port in the aggregator's related ports
+		/* search the port in the aggregator's related ports */
 		for (temp_port = temp_aggregator->lag_ports; temp_port;
 		     prev_port = temp_port,
 			     temp_port = temp_port->next_port_in_aggregator) {
-			if (temp_port == port) { // the aggregator found - detach the port from this aggregator
+			if (temp_port == port) {
+				/* the aggregator found
+				   detach the port from this aggregator */
 				if (prev_port)
-					prev_port->next_port_in_aggregator = temp_port->next_port_in_aggregator;
+					prev_port->next_port_in_aggregator =
+					     temp_port->next_port_in_aggregator;
 				else
-					temp_aggregator->lag_ports = temp_port->next_port_in_aggregator;
+					temp_aggregator->lag_ports =
+					     temp_port->next_port_in_aggregator;
 				temp_aggregator->num_of_ports--;
 				if (temp_aggregator->num_of_ports == 0) {
 					select_new_active_agg = temp_aggregator->is_active;
-					// clear the aggregator
+					/* clear the aggregator */
 					ad_clear_agg(temp_aggregator);
 					if (select_new_active_agg) {
 						pr_info("%s: Removing an active aggregator\n",
 							slave->dev->master->name);
-						// select new active aggregator
+						/* select new active aggreg */
 						ad_agg_selection_logic(__get_first_agg(port));
 					}
 				}
@@ -2125,17 +2258,18 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
 	if (bond->kill_timers)
 		goto out;
 
-	//check if there are any slaves
+	/* check if there are any slaves */
 	if (bond->slave_cnt == 0)
 		goto re_arm;
 
-	// check if agg_select_timer timer after initialize is timed out
-	if (BOND_AD_INFO(bond).agg_select_timer && !(--BOND_AD_INFO(bond).agg_select_timer)) {
-		// select the active aggregator for the bond
+	/* check if agg_select_timer timer after initialize is timed out */
+	if (BOND_AD_INFO(bond).agg_select_timer &&
+	    !(--BOND_AD_INFO(bond).agg_select_timer)) {
+		/* select the active aggregator for the bond */
 		if ((port = __get_first_port(bond))) {
 			if (!port->slave) {
-				pr_warning("%s: Warning: bond's first port is uninitialized\n",
-					   bond->dev->name);
+				pr_warning("%s: Warning: bond's first port is "
+					   "uninitialized\n", bond->dev->name);
 				goto re_arm;
 			}
 
@@ -2145,8 +2279,9 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
 		bond_3ad_set_carrier(bond);
 	}
 
-	// for each port run the state machines
-	for (port = __get_first_port(bond); port; port = __get_next_port(port)) {
+	/* for each port run the state machines */
+	for (port = __get_first_port(bond); port;
+	     port = __get_next_port(port)) {
 		if (!port->slave) {
 			pr_warning("%s: Warning: Found an uninitialized port\n",
 				   bond->dev->name);
@@ -2165,7 +2300,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
 		ad_mux_machine(port);
 		ad_tx_machine(port);
 
-		// turn off the BEGIN bit, since we already handled it
+		/* turn off the BEGIN bit, since we already handled it */
 		if (port->sm_vars & AD_PORT_BEGIN)
 			port->sm_vars &= ~AD_PORT_BEGIN;
 
@@ -2197,8 +2332,9 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
 		port = &(SLAVE_AD_INFO(slave).port);
 
 		if (!port->slave) {
-			pr_warning("%s: Warning: port of slave %s is uninitialized\n",
-				   slave->dev->name, slave->dev->master->name);
+			pr_warning("%s: Warning: port of slave %s is "
+				   "uninitialized\n", slave->dev->name,
+						      slave->dev->master->name);
 			return;
 		}
 
@@ -2213,24 +2349,26 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
 			break;
 
 		case AD_TYPE_MARKER:
-			// No need to convert fields to Little Endian since we don't use the marker's fields.
+			/* No need to convert fields to Little Endian
+			 *  since we don't use the marker's fields.
+			 */
 
 			switch (((struct bond_marker *)lacpdu)->tlv_type) {
 			case AD_MARKER_INFORMATION_SUBTYPE:
-				pr_debug("Received Marker Information on port %d\n",
-					 port->actor_port_number);
+				pr_debug("Received Marker Information on "
+					 "port %d\n", port->actor_port_number);
 				ad_marker_info_received((struct bond_marker *)lacpdu, port);
 				break;
 
 			case AD_MARKER_RESPONSE_SUBTYPE:
-				pr_debug("Received Marker Response on port %d\n",
-					 port->actor_port_number);
+				pr_debug("Received Marker Response on "
+					 "port %d\n", port->actor_port_number);
 				ad_marker_response_received((struct bond_marker *)lacpdu, port);
 				break;
 
 			default:
-				pr_debug("Received an unknown Marker subtype on slot %d\n",
-					 port->actor_port_number);
+				pr_debug("Received an unknown Marker subtype "
+					 "on slot %d\n", port->actor_port_number);
 			}
 		}
 	}
@@ -2248,10 +2386,11 @@ void bond_3ad_adapter_speed_changed(struct slave *slave)
 
 	port = &(SLAVE_AD_INFO(slave).port);
 
-	// if slave is null, the whole port is not initialized
+	/* if slave is null, the whole port is not initialized */
 	if (!port->slave) {
-		pr_warning("Warning: %s: speed changed for uninitialized port on %s\n",
-			   slave->dev->master->name, slave->dev->name);
+		pr_warning("Warning: %s: speed changed for uninitialized "
+			   "port on %s\n", slave->dev->master->name,
+							      slave->dev->name);
 		return;
 	}
 
@@ -2259,8 +2398,8 @@ void bond_3ad_adapter_speed_changed(struct slave *slave)
 	port->actor_oper_port_key = port->actor_admin_port_key |=
 		(__get_link_speed(port) << 1);
 	pr_debug("Port %d changed speed\n", port->actor_port_number);
-	// there is no need to reselect a new aggregator, just signal the
-	// state machines to reinitialize
+	/* there is no need to reselect a new aggregator, just signal the
+	   state machines to reinitialize */
 	port->sm_vars |= AD_PORT_BEGIN;
 }
 
@@ -2276,10 +2415,11 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave)
 
 	port = &(SLAVE_AD_INFO(slave).port);
 
-	// if slave is null, the whole port is not initialized
+	/* if slave is null, the whole port is not initialized */
 	if (!port->slave) {
-		pr_warning("%s: Warning: duplex changed for uninitialized port on %s\n",
-			   slave->dev->master->name, slave->dev->name);
+		pr_warning("%s: Warning: duplex changed for uninitialized "
+			   "port on %s\n", slave->dev->master->name,
+							      slave->dev->name);
 		return;
 	}
 
@@ -2287,8 +2427,8 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave)
 	port->actor_oper_port_key = port->actor_admin_port_key |=
 		__get_duplex(port);
 	pr_debug("Port %d changed duplex\n", port->actor_port_number);
-	// there is no need to reselect a new aggregator, just signal the
-	// state machines to reinitialize
+	/* there is no need to reselect a new aggregator, just signal the
+	   state machines to reinitialize */
 	port->sm_vars |= AD_PORT_BEGIN;
 }
 
@@ -2305,15 +2445,19 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
 
 	port = &(SLAVE_AD_INFO(slave).port);
 
-	// if slave is null, the whole port is not initialized
+	/* if slave is null, the whole port is not initialized */
 	if (!port->slave) {
-		pr_warning("Warning: %s: link status changed for uninitialized port on %s\n",
-			   slave->dev->master->name, slave->dev->name);
+		pr_warning("Warning: %s: link status changed for uninitialized "
+			   "port on %s\n", slave->dev->master->name,
+							      slave->dev->name);
 		return;
 	}
 
-	// on link down we are zeroing duplex and speed since some of the adaptors(ce1000.lan) report full duplex/speed instead of N/A(duplex) / 0(speed)
-	// on link up we are forcing recheck on the duplex and speed since some of he adaptors(ce1000.lan) report
+	/* on link down we are zeroing duplex and speed since some of the
+	 * adaptors(ce1000.lan) report full duplex/speed instead of N/A
+	 * (duplex) / 0(speed) on link up we are forcing recheck on
+	 * the duplex and speed since some of he adaptors (ce1000.lan) report
+	 */
 	if (link == BOND_LINK_UP) {
 		port->is_enabled = true;
 		port->actor_admin_port_key &= ~AD_DUPLEX_KEY_BITS;
@@ -2329,9 +2473,14 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
 		port->actor_oper_port_key = (port->actor_admin_port_key &=
 					     ~AD_SPEED_KEY_BITS);
 	}
-	//BOND_PRINT_DBG(("Port %d changed link status to %s", port->actor_port_number, ((link == BOND_LINK_UP)?"UP":"DOWN")));
-	// there is no need to reselect a new aggregator, just signal the
-	// state machines to reinitialize
+	/*
+	 BOND_PRINT_DBG(("Port %d changed link status to %s",
+			  port->actor_port_number,
+			  ((link == BOND_LINK_UP)?"UP":"DOWN")));
+	 */
+
+	/* there is no need to reselect a new aggregator, just signal the
+	   state machines to reinitialize */
 	port->sm_vars |= AD_PORT_BEGIN;
 }
 
@@ -2387,7 +2536,8 @@ int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info)
 		ad_info->ports = aggregator->num_of_ports;
 		ad_info->actor_key = aggregator->actor_oper_aggregator_key;
 		ad_info->partner_key = aggregator->partner_oper_aggregator_key;
-		memcpy(ad_info->partner_system, aggregator->partner_system.mac_addr_value, ETH_ALEN);
+		memcpy(ad_info->partner_system,
+			 aggregator->partner_system.mac_addr_value, ETH_ALEN);
 		return 0;
 	}
 
@@ -2441,8 +2591,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
 	}
 
 	if (slave_agg_no >= 0) {
-		pr_err("%s: Error: Couldn't find a slave to tx on for aggregator ID %d\n",
-		       dev->name, agg_id);
+		pr_err("%s: Error: Couldn't find a slave to tx on for "
+			"aggregator ID %d\n", dev->name, agg_id);
 		goto out;
 	}
 
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h
index b28baff..55c8f42 100644
--- a/drivers/net/bonding/bond_3ad.h
+++ b/drivers/net/bonding/bond_3ad.h
@@ -28,7 +28,7 @@
 #include <linux/netdevice.h>
 #include <linux/if_ether.h>
 
-// General definitions
+/* General definitions */
 #define PKT_TYPE_LACPDU         cpu_to_be16(ETH_P_SLOW)
 #define AD_TIMER_INTERVAL       100 /*msec*/
 
@@ -47,54 +47,54 @@ enum {
 	BOND_AD_COUNT = 2,
 };
 
-// rx machine states(43.4.11 in the 802.3ad standard)
+/* rx machine states(43.4.11 in the 802.3ad standard) */
 typedef enum {
 	AD_RX_DUMMY,
-	AD_RX_INITIALIZE,     // rx Machine
-	AD_RX_PORT_DISABLED,  // rx Machine
-	AD_RX_LACP_DISABLED,  // rx Machine
-	AD_RX_EXPIRED,	      // rx Machine
-	AD_RX_DEFAULTED,      // rx Machine
-	AD_RX_CURRENT	      // rx Machine
+	AD_RX_INITIALIZE,
+	AD_RX_PORT_DISABLED,
+	AD_RX_LACP_DISABLED,
+	AD_RX_EXPIRED,
+	AD_RX_DEFAULTED,
+	AD_RX_CURRENT
 } rx_states_t;
 
-// periodic machine states(43.4.12 in the 802.3ad standard)
+/* periodic machine states(43.4.12 in the 802.3ad standard) */
 typedef enum {
 	AD_PERIODIC_DUMMY,
-	AD_NO_PERIODIC,	       // periodic machine
-	AD_FAST_PERIODIC,      // periodic machine
-	AD_SLOW_PERIODIC,      // periodic machine
-	AD_PERIODIC_TX	   // periodic machine
+	AD_NO_PERIODIC,
+	AD_FAST_PERIODIC,
+	AD_SLOW_PERIODIC,
+	AD_PERIODIC_TX
 } periodic_states_t;
 
-// mux machine states(43.4.13 in the 802.3ad standard)
+/* mux machine states(43.4.13 in the 802.3ad standard) */
 typedef enum {
 	AD_MUX_DUMMY,
-	AD_MUX_DETACHED,       // mux machine
-	AD_MUX_WAITING,	       // mux machine
-	AD_MUX_ATTACHED,       // mux machine
-	AD_MUX_COLLECTING_DISTRIBUTING // mux machine
+	AD_MUX_DETACHED,
+	AD_MUX_WAITING,
+	AD_MUX_ATTACHED,
+	AD_MUX_COLLECTING_DISTRIBUTING
 } mux_states_t;
 
-// tx machine states(43.4.15 in the 802.3ad standard)
+/* tx machine states(43.4.15 in the 802.3ad standard) */
 typedef enum {
 	AD_TX_DUMMY,
-	AD_TRANSMIT	   // tx Machine
+	AD_TRANSMIT
 } tx_states_t;
 
-// rx indication types
+/* rx indication types */
 typedef enum {
-	AD_TYPE_LACPDU = 1,    // type lacpdu
-	AD_TYPE_MARKER	   // type marker
+	AD_TYPE_LACPDU = 1,
+	AD_TYPE_MARKER
 } pdu_type_t;
 
-// rx marker indication types
+/* rx marker indication types */
 typedef enum {
-	AD_MARKER_INFORMATION_SUBTYPE = 1, // marker imformation subtype
-	AD_MARKER_RESPONSE_SUBTYPE     // marker response subtype
+	AD_MARKER_INFORMATION_SUBTYPE = 1,
+	AD_MARKER_RESPONSE_SUBTYPE
 } bond_marker_subtype_t;
 
-// timers types(43.4.9 in the 802.3ad standard)
+/* timers types(43.4.9 in the 802.3ad standard) */
 typedef enum {
 	AD_CURRENT_WHILE_TIMER,
 	AD_ACTOR_CHURN_TIMER,
@@ -105,35 +105,37 @@ typedef enum {
 
 #pragma pack(1)
 
-// Link Aggregation Control Protocol(LACP) data unit structure(43.4.2.2 in the 802.3ad standard)
+/* Link Aggregation Control Protocol(LACP) data unit
+ * structure(43.4.2.2 in the 802.3ad standard)
+ */
 typedef struct lacpdu {
-	u8 subtype;		     // = LACP(= 0x01)
+	u8 subtype;		          /* = LACP(= 0x01) */
 	u8 version_number;
-	u8 tlv_type_actor_info;	      // = actor information(type/length/value)
-	u8 actor_information_length; // = 20
+	u8 tlv_type_actor_info;	          /* = actor info(type/length/value)*/
+	u8 actor_information_length;      /* = 20 */
 	__be16 actor_system_priority;
 	struct mac_addr actor_system;
 	__be16 actor_key;
 	__be16 actor_port_priority;
 	__be16 actor_port;
 	u8 actor_state;
-	u8 reserved_3_1[3];	     // = 0
-	u8 tlv_type_partner_info;     // = partner information
-	u8 partner_information_length;	 // = 20
+	u8 reserved_3_1[3];	          /* = 0 */
+	u8 tlv_type_partner_info;         /* = partner information */
+	u8 partner_information_length;	  /* = 20 */
 	__be16 partner_system_priority;
 	struct mac_addr partner_system;
 	__be16 partner_key;
 	__be16 partner_port_priority;
 	__be16 partner_port;
 	u8 partner_state;
-	u8 reserved_3_2[3];	     // = 0
-	u8 tlv_type_collector_info;	  // = collector information
-	u8 collector_information_length; // = 16
+	u8 reserved_3_2[3];	          /* = 0 */
+	u8 tlv_type_collector_info;	  /* = collector information */
+	u8 collector_information_length;  /* = 16 */
 	__be16 collector_max_delay;
 	u8 reserved_12[12];
-	u8 tlv_type_terminator;	     // = terminator
-	u8 terminator_length;	     // = 0
-	u8 reserved_50[50];	     // = 0
+	u8 tlv_type_terminator;	          /* = terminator */
+	u8 terminator_length;	          /* = 0 */
+	u8 reserved_50[50];	          /* = 0 */
 } lacpdu_t;
 
 typedef struct lacpdu_header {
@@ -141,20 +143,20 @@ typedef struct lacpdu_header {
 	struct lacpdu lacpdu;
 } lacpdu_header_t;
 
-// Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard)
+/* Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard) */
 typedef struct bond_marker {
-	u8 subtype;		 //  = 0x02  (marker PDU)
-	u8 version_number;	 //  = 0x01
-	u8 tlv_type;		 //  = 0x01  (marker information)
-	//  = 0x02  (marker response information)
-	u8 marker_length;	 //  = 0x16
-	u16 requester_port;	 //   The number assigned to the port by the requester
-	struct mac_addr requester_system;      //   The requester's system id
-	u32 requester_transaction_id;	//   The transaction id allocated by the requester,
-	u16 pad;		 //  = 0
-	u8 tlv_type_terminator;	     //  = 0x00
-	u8 terminator_length;	     //  = 0x00
-	u8 reserved_90[90];	     //  = 0
+	u8 subtype;			  /* = 0x02 (marker PDU) */
+	u8 version_number;		  /* = 0x01 */
+	u8 tlv_type;			  /* = 0x01 (marker information)
+					   * = 0x02  (marker response info */
+	u8 marker_length;		  /* = 0x16 */
+	u16 requester_port;
+	struct mac_addr requester_system; /* The requester's system id */
+	u32 requester_transaction_id;
+	u16 pad;			  /* = 0 */
+	u8 tlv_type_terminator;		  /* = 0x00 */
+	u8 terminator_length;		  /* = 0x00 */
+	u8 reserved_90[90];		  /* = 0 */
 } bond_marker_t;
 
 typedef struct bond_marker_header {
@@ -173,7 +175,7 @@ struct port;
 #pragma pack(8)
 #endif
 
-// aggregator structure(43.4.5 in the 802.3ad standard)
+/* aggregator structure(43.4.5 in the 802.3ad standard) */
 typedef struct aggregator {
 	struct mac_addr aggregator_mac_address;
 	u16 aggregator_identifier;
@@ -183,12 +185,13 @@ typedef struct aggregator {
 	struct mac_addr partner_system;
 	u16 partner_system_priority;
 	u16 partner_oper_aggregator_key;
-	u16 receive_state;		// BOOLEAN
-	u16 transmit_state;		// BOOLEAN
+	u16 receive_state;		/* BOOLEAN */
+	u16 transmit_state;		/* BOOLEAN */
 	struct port *lag_ports;
-	// ****** PRIVATE PARAMETERS ******
-	struct slave *slave;	    // pointer to the bond slave that this aggregator belongs to
-	u16 is_active;	    // BOOLEAN. Indicates if this aggregator is active
+	/* ****** PRIVATE PARAMETERS ****** */
+	struct slave *slave; /* poiter to the bond slave
+				that this aggregator belongs to */
+	u16 is_active;	     /* BOOLEAN. Indicates if the aggregator is active*/
 	u16 num_of_ports;
 } aggregator_t;
 
@@ -201,12 +204,18 @@ struct port_params {
 	u16 port_state;
 };
 
-// port structure(43.4.6 in the 802.3ad standard)
+/* port structure(43.4.6 in the 802.3ad standard) */
 typedef struct port {
 	u16 actor_port_number;
 	u16 actor_port_priority;
-	struct mac_addr actor_system;	       // This parameter is added here although it is not specified in the standard, just for simplification
-	u16 actor_system_priority;	 // This parameter is added here although it is not specified in the standard, just for simplification
+
+	/* in a attempt to simplify operations the
+	 * following two elements were included here
+	 * despite they are not specified in the standard
+	 */
+	struct mac_addr actor_system;
+	u16 actor_system_priority;
+
 	u16 actor_port_aggregator_identifier;
 	bool ntt;
 	u16 actor_admin_port_key;
@@ -219,21 +228,21 @@ typedef struct port {
 
 	bool is_enabled;
 
-	// ****** PRIVATE PARAMETERS ******
-	u16 sm_vars;	      // all state machines variables for this port
-	rx_states_t sm_rx_state;	// state machine rx state
-	u16 sm_rx_timer_counter;    // state machine rx timer counter
-	periodic_states_t sm_periodic_state;// state machine periodic state
-	u16 sm_periodic_timer_counter;	// state machine periodic timer counter
-	mux_states_t sm_mux_state;	// state machine mux state
-	u16 sm_mux_timer_counter;   // state machine mux timer counter
-	tx_states_t sm_tx_state;	// state machine tx state
-	u16 sm_tx_timer_counter;    // state machine tx timer counter(allways on - enter to transmit state 3 time per second)
-	struct slave *slave;	    // pointer to the bond slave that this port belongs to
-	struct aggregator *aggregator;	   // pointer to an aggregator that this port related to
-	struct port *next_port_in_aggregator; // Next port on the linked list of the parent aggregator
-	u32 transaction_id;	    // continuous number for identification of Marker PDU's;
-	struct lacpdu lacpdu;	       // the lacpdu that will be sent for this port
+	/* ****** PRIVATE PARAMETERS ****** */
+	u16 sm_vars;
+	rx_states_t sm_rx_state;
+	u16 sm_rx_timer_counter;
+	periodic_states_t sm_periodic_state;
+	u16 sm_periodic_timer_counter;
+	mux_states_t sm_mux_state;
+	u16 sm_mux_timer_counter;
+	tx_states_t sm_tx_state;
+	u16 sm_tx_timer_counter;
+	struct slave *slave;
+	struct aggregator *aggregator;
+	struct port *next_port_in_aggregator;
+	u32 transaction_id;
+	struct lacpdu lacpdu;
 } port_t;
 
 // system structure
@@ -246,31 +255,30 @@ struct ad_system {
 #endif
 
-// ================= AD Exported structures to the main bonding code ==================
+/* =========== AD Exported structures to the main bonding code ============ */
 #define BOND_AD_INFO(bond)   ((bond)->ad_info)
 #define SLAVE_AD_INFO(slave) ((slave)->ad_info)
 
 struct ad_bond_info {
 	struct ad_system system;	    /* 802.3ad system structure */
-	u32 agg_select_timer;	    // Timer to select aggregator after all adapter's hand shakes
-	u32 agg_select_mode;	    // Mode of selection of active aggregator(bandwidth/count)
-	int lacp_fast;		/* whether fast periodic tx should be
-				 * requested
-				 */
+	u32 agg_select_timer;	            /* aggregator's selected timer */
+	u32 agg_select_mode;	            /* aggregator's selected mode */
+	int lacp_fast;
 	struct timer_list ad_timer;
 	struct packet_type ad_pkt_type;
 };
 
 struct ad_slave_info {
-	struct aggregator aggregator;	    // 802.3ad aggregator structure
-	struct port port;		    // 802.3ad port structure
-	spinlock_t state_machine_lock; /* mutex state machines vs.
-					  incoming LACPDU */
+	struct aggregator aggregator;	    /* 802.3ad aggregator structure */
+	struct port port;		    /* 802.3ad port structure */
+	spinlock_t state_machine_lock;	    /* mutex state machines vs.
+					     * incoming LACPDU */
 	u16 id;
 };
 
-// ================= AD Exported functions to the main bonding code ==================
-void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution, int lacp_fast);
+/* ========= AD Exported functions to the main bonding code ========== */
+void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution,
+								 int lacp_fast);
 int  bond_3ad_bind_slave(struct slave *slave);
 void bond_3ad_unbind_slave(struct slave *slave);
 void bond_3ad_state_machine_handler(struct work_struct *);
@@ -280,7 +288,8 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave);
 void bond_3ad_handle_link_change(struct slave *slave, char link);
 int  bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info);
 int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev);
-int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev);
+int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev,
+			struct packet_type* ptype, struct net_device *orig_dev);
 int bond_3ad_set_carrier(struct bonding *bond);
 #endif //__BOND_3AD_H__
 
-- 
1.7.4.4

^ permalink raw reply related

* [net-next v2 0/6] bnx2x enhancements and date update
From: Dmitry Kravkov @ 2011-05-04 22:22 UTC (permalink / raw)
  To: davem, netdev@vger.kernel.org; +Cc: Eilon Greenstein, Vladislav Zolotarov

Hi Dave,

This re-spin includes following fixes/additions:
patch 1/6: link update now protected with lock
patch 3/6: fixed description formatting
patch 6/6: NEW: fixes more formatting issues: some removed other fixed.

Thanks,
Dmitry




^ permalink raw reply

* [net-next v2 1/6] bnx2x: link report improvements
From: Dmitry Kravkov @ 2011-05-04 22:22 UTC (permalink / raw)
  To: davem, netdev@vger.kernel.org; +Cc: Eilon Greenstein, Vladislav Zolotarov

From: Vladislav Zolotarov <vladz@broadcom.com>

To avoid link notification duplication

Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: Vladislav Zolotarov <vladz@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>

---
 drivers/net/bnx2x/bnx2x.h      |   21 +++++++
 drivers/net/bnx2x/bnx2x_cmn.c  |  130 +++++++++++++++++++++++++++++++++-------
 drivers/net/bnx2x/bnx2x_cmn.h  |    5 +-
 drivers/net/bnx2x/bnx2x_main.c |   21 +++----
 4 files changed, 142 insertions(+), 35 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 9e87417..1a005a4 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -893,6 +893,22 @@ typedef enum {
 	(&bp->def_status_blk->sp_sb.\
 	index_values[HC_SP_INDEX_EQ_CONS])
 
+/* This is a data that will be used to create a link report message.
+ * We will keep the data used for the last link report in order
+ * to prevent reporting the same link parameters twice.
+ */
+struct bnx2x_link_report_data {
+	u16 line_speed;			/* Effective line speed */
+	unsigned long link_report_flags;/* BNX2X_LINK_REPORT_XXX flags */
+};
+
+enum {
+	BNX2X_LINK_REPORT_FD,		/* Full DUPLEX */
+	BNX2X_LINK_REPORT_LINK_DOWN,
+	BNX2X_LINK_REPORT_RX_FC_ON,
+	BNX2X_LINK_REPORT_TX_FC_ON,
+};
+
 struct bnx2x {
 	/* Fields used in the tx and intr/napi performance paths
 	 * are grouped together in the beginning of the structure
@@ -1025,6 +1041,9 @@ struct bnx2x {
 
 	struct link_params	link_params;
 	struct link_vars	link_vars;
+	u32			link_cnt;
+	struct bnx2x_link_report_data last_reported_link;
+
 	struct mdio_if_info	mdio;
 
 	struct bnx2x_common	common;
@@ -1441,6 +1460,8 @@ struct bnx2x_func_init_params {
 #define WAIT_RAMROD_POLL	0x01
 #define WAIT_RAMROD_COMMON	0x02
 
+void bnx2x_read_mf_cfg(struct bnx2x *bp);
+
 /* dmae */
 void bnx2x_read_dmae(struct bnx2x *bp, u32 src_addr, u32 len32);
 void bnx2x_write_dmae(struct bnx2x *bp, dma_addr_t dma_addr, u32 dst_addr,
diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c
index 8729061..cab2af2 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/bnx2x/bnx2x_cmn.c
@@ -758,35 +758,120 @@ u16 bnx2x_get_mf_speed(struct bnx2x *bp)
 	return line_speed;
 }
 
+/**
+ * bnx2x_fill_report_data - fill Link report data according to the current link
+ * configuration.
+ *
+ * @bp:		driver handle
+ * @data:	link state to update
+ *
+ * It uses a none-atomic bit operations because is called under the mutex.
+ */
+static inline void bnx2x_fill_report_data(struct bnx2x *bp,
+					  struct bnx2x_link_report_data *data)
+{
+	u16 line_speed = bnx2x_get_mf_speed(bp);
+
+	memset(data, 0, sizeof(*data));
+
+	/* Fill the report data: efective line speed */
+	data->line_speed = line_speed;
+
+	/* Link is down */
+	if (!bp->link_vars.link_up || (bp->flags & MF_FUNC_DIS))
+		__set_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+			  &data->link_report_flags);
+
+	/* Full DUPLEX */
+	if (bp->link_vars.duplex == DUPLEX_FULL)
+		__set_bit(BNX2X_LINK_REPORT_FD, &data->link_report_flags);
+
+	/* Rx Flow Control is ON */
+	if (bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_RX)
+		__set_bit(BNX2X_LINK_REPORT_RX_FC_ON, &data->link_report_flags);
+
+	/* Tx Flow Control is ON */
+	if (bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_TX)
+		__set_bit(BNX2X_LINK_REPORT_TX_FC_ON, &data->link_report_flags);
+}
+
+/**
+ * bnx2x_link_report - report link status to OS.
+ *
+ * @bp:		driver handle
+ *
+ * Calls the __bnx2x_link_report() under the same locking scheme
+ * as a link/PHY state managing code to ensure a consistent link
+ * reporting.
+ */
+
 void bnx2x_link_report(struct bnx2x *bp)
 {
-	if (bp->flags & MF_FUNC_DIS) {
-		netif_carrier_off(bp->dev);
-		netdev_err(bp->dev, "NIC Link is Down\n");
-		return;
-	}
+	bnx2x_acquire_phy_lock(bp);
+	__bnx2x_link_report(bp);
+	bnx2x_release_phy_lock(bp);
+}
 
-	if (bp->link_vars.link_up) {
-		u16 line_speed;
+/**
+ * __bnx2x_link_report - updates the current link status state
+ * and reports it.
+ *
+ * @bp:		driver handle
+ *
+ * Should be called under the phy_lock.
+ */
+void __bnx2x_link_report(struct bnx2x *bp)
+{
+	struct bnx2x_link_report_data cur_data;
 
-		if (bp->state == BNX2X_STATE_OPEN)
-			netif_carrier_on(bp->dev);
-		netdev_info(bp->dev, "NIC Link is Up, ");
+	/* reread mf_cfg */
+	if (!CHIP_IS_E1(bp))
+		bnx2x_read_mf_cfg(bp);
+
+	/* Read the current link report info */
+	bnx2x_fill_report_data(bp, &cur_data);
+
+	/* Don't report link down or exactly the same link status twice */
+	if (!memcmp(&cur_data, &bp->last_reported_link, sizeof(cur_data)) ||
+	    (test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+		      &bp->last_reported_link.link_report_flags) &&
+	     test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+		      &cur_data.link_report_flags)))
+		return;
+
+	bp->link_cnt++;
 
-		line_speed = bnx2x_get_mf_speed(bp);
+	/* We are going to report a new link parameters now -
+	 * remember the current data for the next time.
+	 */
+	memcpy(&bp->last_reported_link, &cur_data, sizeof(cur_data));
 
-		pr_cont("%d Mbps ", line_speed);
+	if (test_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+		     &cur_data.link_report_flags)) {
+		netif_carrier_off(bp->dev);
+		netdev_err(bp->dev, "NIC Link is Down\n");
+		return;
+	} else {
+		netif_carrier_on(bp->dev);
+		netdev_info(bp->dev, "NIC Link is Up, ");
+		pr_cont("%d Mbps ", cur_data.line_speed);
 
-		if (bp->link_vars.duplex == DUPLEX_FULL)
+		if (test_and_clear_bit(BNX2X_LINK_REPORT_FD,
+				       &cur_data.link_report_flags))
 			pr_cont("full duplex");
 		else
 			pr_cont("half duplex");
 
-		if (bp->link_vars.flow_ctrl != BNX2X_FLOW_CTRL_NONE) {
-			if (bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_RX) {
+		/* Handle the FC at the end so that only these flags would be
+		 * possibly set. This way we may easily check if there is no FC
+		 * enabled.
+		 */
+		if (cur_data.link_report_flags) {
+			if (test_bit(BNX2X_LINK_REPORT_RX_FC_ON,
+				     &cur_data.link_report_flags)) {
 				pr_cont(", receive ");
-				if (bp->link_vars.flow_ctrl &
-				    BNX2X_FLOW_CTRL_TX)
+				if (test_bit(BNX2X_LINK_REPORT_TX_FC_ON,
+				     &cur_data.link_report_flags))
 					pr_cont("& transmit ");
 			} else {
 				pr_cont(", transmit ");
@@ -794,10 +879,6 @@ void bnx2x_link_report(struct bnx2x *bp)
 			pr_cont("flow control ON");
 		}
 		pr_cont("\n");
-
-	} else { /* link_down */
-		netif_carrier_off(bp->dev);
-		netdev_err(bp->dev, "NIC Link is Down\n");
 	}
 }
 
@@ -1345,6 +1426,13 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
 
 	bp->state = BNX2X_STATE_OPENING_WAIT4_LOAD;
 
+	/* Set the initial link reported state to link down */
+	bnx2x_acquire_phy_lock(bp);
+	memset(&bp->last_reported_link, 0, sizeof(bp->last_reported_link));
+	__set_bit(BNX2X_LINK_REPORT_LINK_DOWN,
+		&bp->last_reported_link.link_report_flags);
+	bnx2x_release_phy_lock(bp);
+
 	/* must be called before memory allocation and HW init */
 	bnx2x_ilt_set_info(bp);
 
diff --git a/drivers/net/bnx2x/bnx2x_cmn.h b/drivers/net/bnx2x/bnx2x_cmn.h
index 1cdab69..007f294 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/bnx2x/bnx2x_cmn.h
@@ -67,11 +67,12 @@ void bnx2x__link_status_update(struct bnx2x *bp);
  * Report link status to upper layer
  *
  * @param bp
- *
- * @return int
  */
 void bnx2x_link_report(struct bnx2x *bp);
 
+/* None-atomic version of bnx2x_link_report() */
+void __bnx2x_link_report(struct bnx2x *bp);
+
 /**
  * calculates MF speed according to current linespeed and MF
  * configuration
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index bfd7ac9..3f4ff41 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -2036,7 +2036,7 @@ static int bnx2x_get_cmng_fns_mode(struct bnx2x *bp)
 	return CMNG_FNS_NONE;
 }
 
-static void bnx2x_read_mf_cfg(struct bnx2x *bp)
+void bnx2x_read_mf_cfg(struct bnx2x *bp)
 {
 	int vn, n = (CHIP_MODE_IS_4_PORT(bp) ? 2 : 1);
 
@@ -2123,7 +2123,6 @@ static inline void bnx2x_link_sync_notify(struct bnx2x *bp)
 /* This function is called upon link interrupt */
 static void bnx2x_link_attn(struct bnx2x *bp)
 {
-	u32 prev_link_status = bp->link_vars.link_status;
 	/* Make sure that we are synced with the current statistics */
 	bnx2x_stats_handle(bp, STATS_EVENT_STOP);
 
@@ -2168,17 +2167,15 @@ static void bnx2x_link_attn(struct bnx2x *bp)
 			   "single function mode without fairness\n");
 	}
 
+	__bnx2x_link_report(bp);
+
 	if (IS_MF(bp))
 		bnx2x_link_sync_notify(bp);
-
-	/* indicate link status only if link status actually changed */
-	if (prev_link_status != bp->link_vars.link_status)
-		bnx2x_link_report(bp);
 }
 
 void bnx2x__link_status_update(struct bnx2x *bp)
 {
-	if ((bp->state != BNX2X_STATE_OPEN) || (bp->flags & MF_FUNC_DIS))
+	if (bp->state != BNX2X_STATE_OPEN)
 		return;
 
 	bnx2x_link_status_update(&bp->link_params, &bp->link_vars);
@@ -2188,10 +2185,6 @@ void bnx2x__link_status_update(struct bnx2x *bp)
 	else
 		bnx2x_stats_handle(bp, STATS_EVENT_STOP);
 
-	/* the link status update could be the result of a DCC event
-	   hence re-read the shmem mf configuration */
-	bnx2x_read_mf_cfg(bp);
-
 	/* indicate link status */
 	bnx2x_link_report(bp);
 }
@@ -3120,10 +3113,14 @@ static inline void bnx2x_attn_int_deasserted3(struct bnx2x *bp, u32 attn)
 			if (val & DRV_STATUS_SET_MF_BW)
 				bnx2x_set_mf_bw(bp);
 
-			bnx2x__link_status_update(bp);
 			if ((bp->port.pmf == 0) && (val & DRV_STATUS_PMF))
 				bnx2x_pmf_update(bp);
 
+			/* Always call it here: bnx2x_link_report() will
+			 * prevent the link indication duplication.
+			 */
+			bnx2x__link_status_update(bp);
+
 			if (bp->port.pmf &&
 			    (val & DRV_STATUS_DCBX_NEGOTIATION_RESULTS) &&
 				bp->dcbx_enabled > 0)
-- 
1.7.2.2






^ permalink raw reply related

* [net-next v2 5/6] bnx2x: update year to 2011 and version to 1.62.12-0
From: Dmitry Kravkov @ 2011-05-04 22:23 UTC (permalink / raw)
  To: netdev@vger.kernel.org, David Miller; +Cc: Eilon Greenstein

Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
 drivers/net/bnx2x/bnx2x.h             |    6 +++---
 drivers/net/bnx2x/bnx2x_cmn.c         |    2 +-
 drivers/net/bnx2x/bnx2x_cmn.h         |    2 +-
 drivers/net/bnx2x/bnx2x_dcb.c         |    2 +-
 drivers/net/bnx2x/bnx2x_dcb.h         |    2 +-
 drivers/net/bnx2x/bnx2x_ethtool.c     |    2 +-
 drivers/net/bnx2x/bnx2x_fw_defs.h     |    2 +-
 drivers/net/bnx2x/bnx2x_fw_file_hdr.h |    2 +-
 drivers/net/bnx2x/bnx2x_hsi.h         |    2 +-
 drivers/net/bnx2x/bnx2x_init.h        |    2 +-
 drivers/net/bnx2x/bnx2x_init_ops.h    |    2 +-
 drivers/net/bnx2x/bnx2x_main.c        |    2 +-
 drivers/net/bnx2x/bnx2x_reg.h         |    2 +-
 drivers/net/bnx2x/bnx2x_stats.c       |    2 +-
 drivers/net/bnx2x/bnx2x_stats.h       |    2 +-
 15 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 86e23c7..22a2045 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -1,6 +1,6 @@
 /* bnx2x.h: Broadcom Everest network driver.
  *
- * Copyright (c) 2007-2010 Broadcom Corporation
+ * Copyright (c) 2007-2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,8 +22,8 @@
  * (you will need to reboot afterwards) */
 /* #define BNX2X_STOP_ON_ERROR */
 
-#define DRV_MODULE_VERSION      "1.62.11-0"
-#define DRV_MODULE_RELDATE      "2011/01/31"
+#define DRV_MODULE_VERSION      "1.62.12-0"
+#define DRV_MODULE_RELDATE      "2011/03/20"
 #define BNX2X_BC_VER            0x040200
 
 #define BNX2X_MULTI_QUEUE
diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c
index 9632f85..8c63cb7 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/bnx2x/bnx2x_cmn.c
@@ -1,6 +1,6 @@
 /* bnx2x_cmn.c: Broadcom Everest network driver.
  *
- * Copyright (c) 2007-2010 Broadcom Corporation
+ * Copyright (c) 2007-2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/bnx2x/bnx2x_cmn.h b/drivers/net/bnx2x/bnx2x_cmn.h
index b50570c..cdaf64e 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/bnx2x/bnx2x_cmn.h
@@ -1,6 +1,6 @@
 /* bnx2x_cmn.h: Broadcom Everest network driver.
  *
- * Copyright (c) 2007-2010 Broadcom Corporation
+ * Copyright (c) 2007-2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/bnx2x/bnx2x_dcb.c b/drivers/net/bnx2x/bnx2x_dcb.c
index 9a24d79..919d6fa 100644
--- a/drivers/net/bnx2x/bnx2x_dcb.c
+++ b/drivers/net/bnx2x/bnx2x_dcb.c
@@ -1,6 +1,6 @@
 /* bnx2x_dcb.c: Broadcom Everest network driver.
  *
- * Copyright 2009-2010 Broadcom Corporation
+ * Copyright 2009-2011 Broadcom Corporation
  *
  * Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
diff --git a/drivers/net/bnx2x/bnx2x_dcb.h b/drivers/net/bnx2x/bnx2x_dcb.h
index 71b8eda..369d592 100644
--- a/drivers/net/bnx2x/bnx2x_dcb.h
+++ b/drivers/net/bnx2x/bnx2x_dcb.h
@@ -1,6 +1,6 @@
 /* bnx2x_dcb.h: Broadcom Everest network driver.
  *
- * Copyright 2009-2010 Broadcom Corporation
+ * Copyright 2009-2011 Broadcom Corporation
  *
  * Unless you and Broadcom execute a separate written software license
  * agreement governing use of this software, this software is licensed to you
diff --git a/drivers/net/bnx2x/bnx2x_ethtool.c b/drivers/net/bnx2x/bnx2x_ethtool.c
index 14ed2aa..611a21e 100644
--- a/drivers/net/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/bnx2x/bnx2x_ethtool.c
@@ -1,6 +1,6 @@
 /* bnx2x_ethtool.c: Broadcom Everest network driver.
  *
- * Copyright (c) 2007-2010 Broadcom Corporation
+ * Copyright (c) 2007-2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/bnx2x/bnx2x_fw_defs.h b/drivers/net/bnx2x/bnx2x_fw_defs.h
index f4e5b1c..9fe3678 100644
--- a/drivers/net/bnx2x/bnx2x_fw_defs.h
+++ b/drivers/net/bnx2x/bnx2x_fw_defs.h
@@ -1,6 +1,6 @@
 /* bnx2x_fw_defs.h: Broadcom Everest network driver.
  *
- * Copyright (c) 2007-2010 Broadcom Corporation
+ * Copyright (c) 2007-2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/bnx2x/bnx2x_fw_file_hdr.h b/drivers/net/bnx2x/bnx2x_fw_file_hdr.h
index f807262..f4a07fb 100644
--- a/drivers/net/bnx2x/bnx2x_fw_file_hdr.h
+++ b/drivers/net/bnx2x/bnx2x_fw_file_hdr.h
@@ -1,6 +1,6 @@
 /* bnx2x_fw_file_hdr.h: FW binary file header structure.
  *
- * Copyright (c) 2007-2009 Broadcom Corporation
+ * Copyright (c) 2007-2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/bnx2x/bnx2x_hsi.h b/drivers/net/bnx2x/bnx2x_hsi.h
index be503cc..6381a54 100644
--- a/drivers/net/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/bnx2x/bnx2x_hsi.h
@@ -1,6 +1,6 @@
 /* bnx2x_hsi.h: Broadcom Everest network driver.
  *
- * Copyright (c) 2007-2010 Broadcom Corporation
+ * Copyright (c) 2007-2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/bnx2x/bnx2x_init.h b/drivers/net/bnx2x/bnx2x_init.h
index fa6dbe3..d539920 100644
--- a/drivers/net/bnx2x/bnx2x_init.h
+++ b/drivers/net/bnx2x/bnx2x_init.h
@@ -1,7 +1,7 @@
 /* bnx2x_init.h: Broadcom Everest network driver.
  *               Structures and macroes needed during the initialization.
  *
- * Copyright (c) 2007-2009 Broadcom Corporation
+ * Copyright (c) 2007-2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/bnx2x/bnx2x_init_ops.h b/drivers/net/bnx2x/bnx2x_init_ops.h
index 66df29f..aafd023 100644
--- a/drivers/net/bnx2x/bnx2x_init_ops.h
+++ b/drivers/net/bnx2x/bnx2x_init_ops.h
@@ -2,7 +2,7 @@
  *               Static functions needed during the initialization.
  *               This file is "included" in bnx2x_main.c.
  *
- * Copyright (c) 2007-2010 Broadcom Corporation
+ * Copyright (c) 2007-2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index 3ddc436..c8e5ff0 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -1,6 +1,6 @@
 /* bnx2x_main.c: Broadcom Everest network driver.
  *
- * Copyright (c) 2007-2010 Broadcom Corporation
+ * Copyright (c) 2007-2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/bnx2x/bnx2x_reg.h b/drivers/net/bnx2x/bnx2x_reg.h
index 1c89f19..eb959be 100644
--- a/drivers/net/bnx2x/bnx2x_reg.h
+++ b/drivers/net/bnx2x/bnx2x_reg.h
@@ -1,6 +1,6 @@
 /* bnx2x_reg.h: Broadcom Everest network driver.
  *
- * Copyright (c) 2007-2010 Broadcom Corporation
+ * Copyright (c) 2007-2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/bnx2x/bnx2x_stats.c b/drivers/net/bnx2x/bnx2x_stats.c
index 3445ded..e535bfa 100644
--- a/drivers/net/bnx2x/bnx2x_stats.c
+++ b/drivers/net/bnx2x/bnx2x_stats.c
@@ -1,6 +1,6 @@
 /* bnx2x_stats.c: Broadcom Everest network driver.
  *
- * Copyright (c) 2007-2010 Broadcom Corporation
+ * Copyright (c) 2007-2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/drivers/net/bnx2x/bnx2x_stats.h b/drivers/net/bnx2x/bnx2x_stats.h
index 596798c..45d14d8 100644
--- a/drivers/net/bnx2x/bnx2x_stats.h
+++ b/drivers/net/bnx2x/bnx2x_stats.h
@@ -1,6 +1,6 @@
 /* bnx2x_stats.h: Broadcom Everest network driver.
  *
- * Copyright (c) 2007-2010 Broadcom Corporation
+ * Copyright (c) 2007-2011 Broadcom Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
-- 
1.7.2.2






^ permalink raw reply related

* [net-next v2 4/6] bnx2x: improve memory handling, low memory recovery flows
From: Dmitry Kravkov @ 2011-05-04 22:23 UTC (permalink / raw)
  To: David Miller, netdev@vger.kernel.org; +Cc: Eilon Greenstein


Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
 drivers/net/bnx2x/bnx2x.h         |    3 +-
 drivers/net/bnx2x/bnx2x_cmn.c     |  402 +++++++++++++++++++++++++++++-------
 drivers/net/bnx2x/bnx2x_cmn.h     |  128 ++++++++++---
 drivers/net/bnx2x/bnx2x_ethtool.c |    3 +-
 drivers/net/bnx2x/bnx2x_main.c    |  189 ++----------------
 5 files changed, 449 insertions(+), 276 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index 9e87417..d57dab1 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -473,7 +473,8 @@ struct bnx2x_fastpath {
 #define NUM_RX_BD			(RX_DESC_CNT * NUM_RX_RINGS)
 #define MAX_RX_BD			(NUM_RX_BD - 1)
 #define MAX_RX_AVAIL			(MAX_RX_DESC_CNT * NUM_RX_RINGS - 2)
-#define MIN_RX_AVAIL			128
+#define MIN_RX_SIZE_TPA			72
+#define MIN_RX_SIZE_NONTPA		10
 #define INIT_JUMBO_RX_RING_SIZE		MAX_RX_AVAIL
 #define INIT_RX_RING_SIZE		MAX_RX_AVAIL
 #define NEXT_RX_IDX(x)		((((x) & RX_DESC_MASK) == \
diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c
index 8729061..b171b9b 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/bnx2x/bnx2x_cmn.c
@@ -27,6 +27,49 @@
 
 static int bnx2x_setup_irqs(struct bnx2x *bp);
 
+/**
+ * bnx2x_bz_fp - zero content of the fastpath structure.
+ *
+ * @bp:		driver handle
+ * @index:	fastpath index to be zeroed
+ *
+ * Makes sure the contents of the bp->fp[index].napi is kept
+ * intact.
+ */
+static inline void bnx2x_bz_fp(struct bnx2x *bp, int index)
+{
+	struct bnx2x_fastpath *fp = &bp->fp[index];
+	struct napi_struct orig_napi = fp->napi;
+	/* bzero bnx2x_fastpath contents */
+	memset(fp, 0, sizeof(*fp));
+
+	/* Restore the NAPI object as it has been already initialized */
+	fp->napi = orig_napi;
+}
+
+/**
+ * bnx2x_move_fp - move content of the fastpath structure.
+ *
+ * @bp:		driver handle
+ * @from:	source FP index
+ * @to:		destination FP index
+ *
+ * Makes sure the contents of the bp->fp[to].napi is kept
+ * intact.
+ */
+static inline void bnx2x_move_fp(struct bnx2x *bp, int from, int to)
+{
+	struct bnx2x_fastpath *from_fp = &bp->fp[from];
+	struct bnx2x_fastpath *to_fp = &bp->fp[to];
+	struct napi_struct orig_napi = to_fp->napi;
+	/* Move bnx2x_fastpath contents */
+	memcpy(to_fp, from_fp, sizeof(*to_fp));
+	to_fp->index = to;
+
+	/* Restore the NAPI object as it has been already initialized */
+	to_fp->napi = orig_napi;
+}
+
 /* free skb in the packet ring at pos idx
  * return idx of last bd freed
  */
@@ -801,55 +844,6 @@ void bnx2x_link_report(struct bnx2x *bp)
 	}
 }
 
-/* Returns the number of actually allocated BDs */
-static inline int bnx2x_alloc_rx_bds(struct bnx2x_fastpath *fp,
-				      int rx_ring_size)
-{
-	struct bnx2x *bp = fp->bp;
-	u16 ring_prod, cqe_ring_prod;
-	int i;
-
-	fp->rx_comp_cons = 0;
-	cqe_ring_prod = ring_prod = 0;
-	for (i = 0; i < rx_ring_size; i++) {
-		if (bnx2x_alloc_rx_skb(bp, fp, ring_prod) < 0) {
-			BNX2X_ERR("was only able to allocate "
-				  "%d rx skbs on queue[%d]\n", i, fp->index);
-			fp->eth_q_stats.rx_skb_alloc_failed++;
-			break;
-		}
-		ring_prod = NEXT_RX_IDX(ring_prod);
-		cqe_ring_prod = NEXT_RCQ_IDX(cqe_ring_prod);
-		WARN_ON(ring_prod <= i);
-	}
-
-	fp->rx_bd_prod = ring_prod;
-	/* Limit the CQE producer by the CQE ring size */
-	fp->rx_comp_prod = min_t(u16, NUM_RCQ_RINGS*RCQ_DESC_CNT,
-			       cqe_ring_prod);
-	fp->rx_pkt = fp->rx_calls = 0;
-
-	return i;
-}
-
-static inline void bnx2x_alloc_rx_bd_ring(struct bnx2x_fastpath *fp)
-{
-	struct bnx2x *bp = fp->bp;
-	int rx_ring_size = bp->rx_ring_size ? bp->rx_ring_size :
-					      MAX_RX_AVAIL/bp->num_queues;
-
-	rx_ring_size = max_t(int, MIN_RX_AVAIL, rx_ring_size);
-
-	bnx2x_alloc_rx_bds(fp, rx_ring_size);
-
-	/* Warning!
-	 * this will generate an interrupt (to the TSTORM)
-	 * must only be done after chip is initialized
-	 */
-	bnx2x_update_rx_prod(bp, fp, fp->rx_bd_prod, fp->rx_comp_prod,
-			     fp->rx_sge_prod);
-}
-
 void bnx2x_init_rx_rings(struct bnx2x *bp)
 {
 	int func = BP_FUNC(bp);
@@ -858,6 +852,7 @@ void bnx2x_init_rx_rings(struct bnx2x *bp)
 	u16 ring_prod;
 	int i, j;
 
+	/* Allocate TPA resources */
 	for_each_rx_queue(bp, j) {
 		struct bnx2x_fastpath *fp = &bp->fp[j];
 
@@ -865,6 +860,7 @@ void bnx2x_init_rx_rings(struct bnx2x *bp)
 		   "mtu %d  rx_buf_size %d\n", bp->dev->mtu, fp->rx_buf_size);
 
 		if (!fp->disable_tpa) {
+			/* Fill the per-aggregation pool */
 			for (i = 0; i < max_agg_queues; i++) {
 				fp->tpa_pool[i].skb =
 				   netdev_alloc_skb(bp->dev, fp->rx_buf_size);
@@ -919,13 +915,13 @@ void bnx2x_init_rx_rings(struct bnx2x *bp)
 
 		fp->rx_bd_cons = 0;
 
-		bnx2x_set_next_page_rx_bd(fp);
-
-		/* CQ ring */
-		bnx2x_set_next_page_rx_cq(fp);
-
-		/* Allocate BDs and initialize BD ring */
-		bnx2x_alloc_rx_bd_ring(fp);
+		/* Activate BD ring */
+		/* Warning!
+		 * this will generate an interrupt (to the TSTORM)
+		 * must only be done after chip is initialized
+		 */
+		bnx2x_update_rx_prod(bp, fp, fp->rx_bd_prod, fp->rx_comp_prod,
+				     fp->rx_sge_prod);
 
 		if (j != 0)
 			continue;
@@ -959,27 +955,40 @@ static void bnx2x_free_tx_skbs(struct bnx2x *bp)
 	}
 }
 
+static void bnx2x_free_rx_bds(struct bnx2x_fastpath *fp)
+{
+	struct bnx2x *bp = fp->bp;
+	int i;
+
+	/* ring wasn't allocated */
+	if (fp->rx_buf_ring == NULL)
+		return;
+
+	for (i = 0; i < NUM_RX_BD; i++) {
+		struct sw_rx_bd *rx_buf = &fp->rx_buf_ring[i];
+		struct sk_buff *skb = rx_buf->skb;
+
+		if (skb == NULL)
+			continue;
+
+		dma_unmap_single(&bp->pdev->dev,
+				 dma_unmap_addr(rx_buf, mapping),
+				 fp->rx_buf_size, DMA_FROM_DEVICE);
+
+		rx_buf->skb = NULL;
+		dev_kfree_skb(skb);
+	}
+}
+
 static void bnx2x_free_rx_skbs(struct bnx2x *bp)
 {
-	int i, j;
+	int j;
 
 	for_each_rx_queue(bp, j) {
 		struct bnx2x_fastpath *fp = &bp->fp[j];
 
-		for (i = 0; i < NUM_RX_BD; i++) {
-			struct sw_rx_bd *rx_buf = &fp->rx_buf_ring[i];
-			struct sk_buff *skb = rx_buf->skb;
-
-			if (skb == NULL)
-				continue;
-
-			dma_unmap_single(&bp->pdev->dev,
-					 dma_unmap_addr(rx_buf, mapping),
-					 fp->rx_buf_size, DMA_FROM_DEVICE);
+		bnx2x_free_rx_bds(fp);
 
-			rx_buf->skb = NULL;
-			dev_kfree_skb(skb);
-		}
 		if (!fp->disable_tpa)
 			bnx2x_free_tpa_pool(bp, fp, CHIP_IS_E1(bp) ?
 					    ETH_MAX_AGGREGATION_QUEUES_E1 :
@@ -1348,26 +1357,37 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
 	/* must be called before memory allocation and HW init */
 	bnx2x_ilt_set_info(bp);
 
+	/* zero fastpath structures preserving invariants like napi which are
+	 * allocated only once
+	 */
+	for_each_queue(bp, i)
+		bnx2x_bz_fp(bp, i);
+
 	/* Set the receive queues buffer size */
 	bnx2x_set_rx_buf_size(bp);
 
+	for_each_queue(bp, i)
+		bnx2x_fp(bp, i, disable_tpa) =
+					((bp->flags & TPA_ENABLE_FLAG) == 0);
+
+#ifdef BCM_CNIC
+	/* We don't want TPA on FCoE L2 ring */
+	bnx2x_fcoe(bp, disable_tpa) = 1;
+#endif
+
 	if (bnx2x_alloc_mem(bp))
 		return -ENOMEM;
 
+	/* As long as bnx2x_alloc_mem() may possibly update
+	 * bp->num_queues, bnx2x_set_real_num_queues() should always
+	 * come after it.
+	 */
 	rc = bnx2x_set_real_num_queues(bp);
 	if (rc) {
 		BNX2X_ERR("Unable to set real_num_queues\n");
 		goto load_error0;
 	}
 
-	for_each_queue(bp, i)
-		bnx2x_fp(bp, i, disable_tpa) =
-					((bp->flags & TPA_ENABLE_FLAG) == 0);
-
-#ifdef BCM_CNIC
-	/* We don't want TPA on FCoE L2 ring */
-	bnx2x_fcoe(bp, disable_tpa) = 1;
-#endif
 	bnx2x_napi_enable(bp);
 
 	/* Send LOAD_REQUEST command to MCP
@@ -2393,6 +2413,232 @@ int bnx2x_change_mac_addr(struct net_device *dev, void *p)
 	return 0;
 }
 
+static void bnx2x_free_fp_mem_at(struct bnx2x *bp, int fp_index)
+{
+	union host_hc_status_block *sb = &bnx2x_fp(bp, fp_index, status_blk);
+	struct bnx2x_fastpath *fp = &bp->fp[fp_index];
+
+	/* Common */
+#ifdef BCM_CNIC
+	if (IS_FCOE_IDX(fp_index)) {
+		memset(sb, 0, sizeof(union host_hc_status_block));
+		fp->status_blk_mapping = 0;
+
+	} else {
+#endif
+		/* status blocks */
+		if (CHIP_IS_E2(bp))
+			BNX2X_PCI_FREE(sb->e2_sb,
+				       bnx2x_fp(bp, fp_index,
+						status_blk_mapping),
+				       sizeof(struct host_hc_status_block_e2));
+		else
+			BNX2X_PCI_FREE(sb->e1x_sb,
+				       bnx2x_fp(bp, fp_index,
+						status_blk_mapping),
+				       sizeof(struct host_hc_status_block_e1x));
+#ifdef BCM_CNIC
+	}
+#endif
+	/* Rx */
+	if (!skip_rx_queue(bp, fp_index)) {
+		bnx2x_free_rx_bds(fp);
+
+		/* fastpath rx rings: rx_buf rx_desc rx_comp */
+		BNX2X_FREE(bnx2x_fp(bp, fp_index, rx_buf_ring));
+		BNX2X_PCI_FREE(bnx2x_fp(bp, fp_index, rx_desc_ring),
+			       bnx2x_fp(bp, fp_index, rx_desc_mapping),
+			       sizeof(struct eth_rx_bd) * NUM_RX_BD);
+
+		BNX2X_PCI_FREE(bnx2x_fp(bp, fp_index, rx_comp_ring),
+			       bnx2x_fp(bp, fp_index, rx_comp_mapping),
+			       sizeof(struct eth_fast_path_rx_cqe) *
+			       NUM_RCQ_BD);
+
+		/* SGE ring */
+		BNX2X_FREE(bnx2x_fp(bp, fp_index, rx_page_ring));
+		BNX2X_PCI_FREE(bnx2x_fp(bp, fp_index, rx_sge_ring),
+			       bnx2x_fp(bp, fp_index, rx_sge_mapping),
+			       BCM_PAGE_SIZE * NUM_RX_SGE_PAGES);
+	}
+
+	/* Tx */
+	if (!skip_tx_queue(bp, fp_index)) {
+		/* fastpath tx rings: tx_buf tx_desc */
+		BNX2X_FREE(bnx2x_fp(bp, fp_index, tx_buf_ring));
+		BNX2X_PCI_FREE(bnx2x_fp(bp, fp_index, tx_desc_ring),
+			       bnx2x_fp(bp, fp_index, tx_desc_mapping),
+			       sizeof(union eth_tx_bd_types) * NUM_TX_BD);
+	}
+	/* end of fastpath */
+}
+
+void bnx2x_free_fp_mem(struct bnx2x *bp)
+{
+	int i;
+	for_each_queue(bp, i)
+		bnx2x_free_fp_mem_at(bp, i);
+}
+
+static inline void set_sb_shortcuts(struct bnx2x *bp, int index)
+{
+	union host_hc_status_block status_blk = bnx2x_fp(bp, index, status_blk);
+	if (CHIP_IS_E2(bp)) {
+		bnx2x_fp(bp, index, sb_index_values) =
+			(__le16 *)status_blk.e2_sb->sb.index_values;
+		bnx2x_fp(bp, index, sb_running_index) =
+			(__le16 *)status_blk.e2_sb->sb.running_index;
+	} else {
+		bnx2x_fp(bp, index, sb_index_values) =
+			(__le16 *)status_blk.e1x_sb->sb.index_values;
+		bnx2x_fp(bp, index, sb_running_index) =
+			(__le16 *)status_blk.e1x_sb->sb.running_index;
+	}
+}
+
+static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index)
+{
+	union host_hc_status_block *sb;
+	struct bnx2x_fastpath *fp = &bp->fp[index];
+	int ring_size = 0;
+
+	/* if rx_ring_size specified - use it */
+	int rx_ring_size = bp->rx_ring_size ? bp->rx_ring_size :
+			   MAX_RX_AVAIL/bp->num_queues;
+
+	/* allocate at least number of buffers required by FW */
+	rx_ring_size = max_t(int, fp->disable_tpa ? MIN_RX_SIZE_NONTPA :
+						    MIN_RX_SIZE_TPA,
+				  rx_ring_size);
+
+	bnx2x_fp(bp, index, bp) = bp;
+	bnx2x_fp(bp, index, index) = index;
+
+	/* Common */
+	sb = &bnx2x_fp(bp, index, status_blk);
+#ifdef BCM_CNIC
+	if (!IS_FCOE_IDX(index)) {
+#endif
+		/* status blocks */
+		if (CHIP_IS_E2(bp))
+			BNX2X_PCI_ALLOC(sb->e2_sb,
+				&bnx2x_fp(bp, index, status_blk_mapping),
+				sizeof(struct host_hc_status_block_e2));
+		else
+			BNX2X_PCI_ALLOC(sb->e1x_sb,
+				&bnx2x_fp(bp, index, status_blk_mapping),
+			    sizeof(struct host_hc_status_block_e1x));
+#ifdef BCM_CNIC
+	}
+#endif
+	set_sb_shortcuts(bp, index);
+
+	/* Tx */
+	if (!skip_tx_queue(bp, index)) {
+		/* fastpath tx rings: tx_buf tx_desc */
+		BNX2X_ALLOC(bnx2x_fp(bp, index, tx_buf_ring),
+				sizeof(struct sw_tx_bd) * NUM_TX_BD);
+		BNX2X_PCI_ALLOC(bnx2x_fp(bp, index, tx_desc_ring),
+				&bnx2x_fp(bp, index, tx_desc_mapping),
+				sizeof(union eth_tx_bd_types) * NUM_TX_BD);
+	}
+
+	/* Rx */
+	if (!skip_rx_queue(bp, index)) {
+		/* fastpath rx rings: rx_buf rx_desc rx_comp */
+		BNX2X_ALLOC(bnx2x_fp(bp, index, rx_buf_ring),
+				sizeof(struct sw_rx_bd) * NUM_RX_BD);
+		BNX2X_PCI_ALLOC(bnx2x_fp(bp, index, rx_desc_ring),
+				&bnx2x_fp(bp, index, rx_desc_mapping),
+				sizeof(struct eth_rx_bd) * NUM_RX_BD);
+
+		BNX2X_PCI_ALLOC(bnx2x_fp(bp, index, rx_comp_ring),
+				&bnx2x_fp(bp, index, rx_comp_mapping),
+				sizeof(struct eth_fast_path_rx_cqe) *
+				NUM_RCQ_BD);
+
+		/* SGE ring */
+		BNX2X_ALLOC(bnx2x_fp(bp, index, rx_page_ring),
+				sizeof(struct sw_rx_page) * NUM_RX_SGE);
+		BNX2X_PCI_ALLOC(bnx2x_fp(bp, index, rx_sge_ring),
+				&bnx2x_fp(bp, index, rx_sge_mapping),
+				BCM_PAGE_SIZE * NUM_RX_SGE_PAGES);
+		/* RX BD ring */
+		bnx2x_set_next_page_rx_bd(fp);
+
+		/* CQ ring */
+		bnx2x_set_next_page_rx_cq(fp);
+
+		/* BDs */
+		ring_size = bnx2x_alloc_rx_bds(fp, rx_ring_size);
+		if (ring_size < rx_ring_size)
+			goto alloc_mem_err;
+	}
+
+	return 0;
+
+/* handles low memory cases */
+alloc_mem_err:
+	BNX2X_ERR("Unable to allocate full memory for queue %d (size %d)\n",
+						index, ring_size);
+	/* FW will drop all packets if queue is not big enough,
+	 * In these cases we disable the queue
+	 * Min size diferent for TPA and non-TPA queues
+	 */
+	if (ring_size < (fp->disable_tpa ?
+				MIN_RX_SIZE_TPA : MIN_RX_SIZE_NONTPA)) {
+			/* release memory allocated for this queue */
+			bnx2x_free_fp_mem_at(bp, index);
+			return -ENOMEM;
+	}
+	return 0;
+}
+
+int bnx2x_alloc_fp_mem(struct bnx2x *bp)
+{
+	int i;
+
+	/**
+	 * 1. Allocate FP for leading - fatal if error
+	 * 2. {CNIC} Allocate FCoE FP - fatal if error
+	 * 3. Allocate RSS - fix number of queues if error
+	 */
+
+	/* leading */
+	if (bnx2x_alloc_fp_mem_at(bp, 0))
+		return -ENOMEM;
+#ifdef BCM_CNIC
+	/* FCoE */
+	if (bnx2x_alloc_fp_mem_at(bp, FCOE_IDX))
+		return -ENOMEM;
+#endif
+	/* RSS */
+	for_each_nondefault_eth_queue(bp, i)
+		if (bnx2x_alloc_fp_mem_at(bp, i))
+			break;
+
+	/* handle memory failures */
+	if (i != BNX2X_NUM_ETH_QUEUES(bp)) {
+		int delta = BNX2X_NUM_ETH_QUEUES(bp) - i;
+
+		WARN_ON(delta < 0);
+#ifdef BCM_CNIC
+		/**
+		 * move non eth FPs next to last eth FP
+		 * must be done in that order
+		 * FCOE_IDX < FWD_IDX < OOO_IDX
+		 */
+
+		/* move FCoE fp */
+		bnx2x_move_fp(bp, FCOE_IDX, FCOE_IDX - delta);
+#endif
+		bp->num_queues -= delta;
+		BNX2X_ERR("Adjusted num of queues from %d to %d\n",
+			  bp->num_queues + delta, bp->num_queues);
+	}
+
+	return 0;
+}
 
 static int bnx2x_setup_irqs(struct bnx2x *bp)
 {
diff --git a/drivers/net/bnx2x/bnx2x_cmn.h b/drivers/net/bnx2x/bnx2x_cmn.h
index 1cdab69..c86a97b 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/bnx2x/bnx2x_cmn.h
@@ -25,6 +25,39 @@
 
 extern int num_queues;
 
+/************************ Macros ********************************/
+#define BNX2X_PCI_FREE(x, y, size) \
+	do { \
+		if (x) { \
+			dma_free_coherent(&bp->pdev->dev, size, (void *)x, y); \
+			x = NULL; \
+			y = 0; \
+		} \
+	} while (0)
+
+#define BNX2X_FREE(x) \
+	do { \
+		if (x) { \
+			kfree((void *)x); \
+			x = NULL; \
+		} \
+	} while (0)
+
+#define BNX2X_PCI_ALLOC(x, y, size) \
+	do { \
+		x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \
+		if (x == NULL) \
+			goto alloc_mem_err; \
+		memset((void *)x, 0, size); \
+	} while (0)
+
+#define BNX2X_ALLOC(x, size) \
+	do { \
+		x = kzalloc(size, GFP_KERNEL); \
+		if (x == NULL) \
+			goto alloc_mem_err; \
+	} while (0)
+
 /*********************** Interfaces ****************************
  *  Functions that need to be implemented by each driver version
  */
@@ -377,6 +410,9 @@ int bnx2x_resume(struct pci_dev *pdev);
 /* Release IRQ vectors */
 void bnx2x_free_irq(struct bnx2x *bp);
 
+void bnx2x_free_fp_mem(struct bnx2x *bp);
+int bnx2x_alloc_fp_mem(struct bnx2x *bp);
+
 void bnx2x_init_rx_rings(struct bnx2x *bp);
 void bnx2x_free_skbs(struct bnx2x *bp);
 void bnx2x_netif_stop(struct bnx2x *bp, int disable_hw);
@@ -883,6 +919,9 @@ static inline void bnx2x_free_rx_sge_range(struct bnx2x *bp,
 {
 	int i;
 
+	if (fp->disable_tpa)
+		return;
+
 	for (i = 0; i < last; i++)
 		bnx2x_free_rx_sge(bp, fp, i);
 }
@@ -911,36 +950,39 @@ static inline void bnx2x_free_tpa_pool(struct bnx2x *bp,
 	}
 }
 
-
-static inline void bnx2x_init_tx_rings(struct bnx2x *bp)
+static inline void bnx2x_init_tx_ring_one(struct bnx2x_fastpath *fp)
 {
-	int i, j;
+	int i;
 
-	for_each_tx_queue(bp, j) {
-		struct bnx2x_fastpath *fp = &bp->fp[j];
+	for (i = 1; i <= NUM_TX_RINGS; i++) {
+		struct eth_tx_next_bd *tx_next_bd =
+			&fp->tx_desc_ring[TX_DESC_CNT * i - 1].next_bd;
 
-		for (i = 1; i <= NUM_TX_RINGS; i++) {
-			struct eth_tx_next_bd *tx_next_bd =
-				&fp->tx_desc_ring[TX_DESC_CNT * i - 1].next_bd;
+		tx_next_bd->addr_hi =
+			cpu_to_le32(U64_HI(fp->tx_desc_mapping +
+				    BCM_PAGE_SIZE*(i % NUM_TX_RINGS)));
+		tx_next_bd->addr_lo =
+			cpu_to_le32(U64_LO(fp->tx_desc_mapping +
+				    BCM_PAGE_SIZE*(i % NUM_TX_RINGS)));
+	}
 
-			tx_next_bd->addr_hi =
-				cpu_to_le32(U64_HI(fp->tx_desc_mapping +
-					    BCM_PAGE_SIZE*(i % NUM_TX_RINGS)));
-			tx_next_bd->addr_lo =
-				cpu_to_le32(U64_LO(fp->tx_desc_mapping +
-					    BCM_PAGE_SIZE*(i % NUM_TX_RINGS)));
-		}
+	SET_FLAG(fp->tx_db.data.header.header, DOORBELL_HDR_DB_TYPE, 1);
+	fp->tx_db.data.zero_fill1 = 0;
+	fp->tx_db.data.prod = 0;
 
-		SET_FLAG(fp->tx_db.data.header.header, DOORBELL_HDR_DB_TYPE, 1);
-		fp->tx_db.data.zero_fill1 = 0;
-		fp->tx_db.data.prod = 0;
+	fp->tx_pkt_prod = 0;
+	fp->tx_pkt_cons = 0;
+	fp->tx_bd_prod = 0;
+	fp->tx_bd_cons = 0;
+	fp->tx_pkt = 0;
+}
 
-		fp->tx_pkt_prod = 0;
-		fp->tx_pkt_cons = 0;
-		fp->tx_bd_prod = 0;
-		fp->tx_bd_cons = 0;
-		fp->tx_pkt = 0;
-	}
+static inline void bnx2x_init_tx_rings(struct bnx2x *bp)
+{
+	int i;
+
+	for_each_tx_queue(bp, i)
+		bnx2x_init_tx_ring_one(&bp->fp[i]);
 }
 
 static inline void bnx2x_set_next_page_rx_bd(struct bnx2x_fastpath *fp)
@@ -995,6 +1037,44 @@ static inline void bnx2x_set_next_page_rx_cq(struct bnx2x_fastpath *fp)
 	}
 }
 
+/* Returns the number of actually allocated BDs */
+static inline int bnx2x_alloc_rx_bds(struct bnx2x_fastpath *fp,
+				      int rx_ring_size)
+{
+	struct bnx2x *bp = fp->bp;
+	u16 ring_prod, cqe_ring_prod;
+	int i;
+
+	fp->rx_comp_cons = 0;
+	cqe_ring_prod = ring_prod = 0;
+
+	/* This routine is called only during fo init so
+	 * fp->eth_q_stats.rx_skb_alloc_failed = 0
+	 */
+	for (i = 0; i < rx_ring_size; i++) {
+		if (bnx2x_alloc_rx_skb(bp, fp, ring_prod) < 0) {
+			fp->eth_q_stats.rx_skb_alloc_failed++;
+			continue;
+		}
+		ring_prod = NEXT_RX_IDX(ring_prod);
+		cqe_ring_prod = NEXT_RCQ_IDX(cqe_ring_prod);
+		WARN_ON(ring_prod <= (i - fp->eth_q_stats.rx_skb_alloc_failed));
+	}
+
+	if (fp->eth_q_stats.rx_skb_alloc_failed)
+		BNX2X_ERR("was only able to allocate "
+			  "%d rx skbs on queue[%d]\n",
+			  (i - fp->eth_q_stats.rx_skb_alloc_failed), fp->index);
+
+	fp->rx_bd_prod = ring_prod;
+	/* Limit the CQE producer by the CQE ring size */
+	fp->rx_comp_prod = min_t(u16, NUM_RCQ_RINGS*RCQ_DESC_CNT,
+			       cqe_ring_prod);
+	fp->rx_pkt = fp->rx_calls = 0;
+
+	return i - fp->eth_q_stats.rx_skb_alloc_failed;
+}
+
 #ifdef BCM_CNIC
 static inline void bnx2x_init_fcoe_fp(struct bnx2x *bp)
 {
diff --git a/drivers/net/bnx2x/bnx2x_ethtool.c b/drivers/net/bnx2x/bnx2x_ethtool.c
index 4f42c31..7556fde 100644
--- a/drivers/net/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/bnx2x/bnx2x_ethtool.c
@@ -1220,7 +1220,8 @@ static int bnx2x_set_ringparam(struct net_device *dev,
 	}
 
 	if ((ering->rx_pending > MAX_RX_AVAIL) ||
-	    (ering->rx_pending < MIN_RX_AVAIL) ||
+	    (ering->rx_pending < (bp->disable_tpa ? MIN_RX_SIZE_NONTPA :
+						    MIN_RX_SIZE_TPA)) ||
 	    (ering->tx_pending > MAX_TX_AVAIL) ||
 	    (ering->tx_pending <= MAX_SKB_FRAGS + 4))
 		return -EINVAL;
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index 69be737..439b8e5 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -4450,7 +4450,7 @@ static void bnx2x_init_fp_sb(struct bnx2x *bp, int fp_idx)
 
 	fp->state = BNX2X_FP_STATE_CLOSED;
 
-	fp->index = fp->cid = fp_idx;
+	fp->cid = fp_idx;
 	fp->cl_id = BP_L_ID(bp) + fp_idx;
 	fp->fw_sb_id = bp->base_fw_ndsb + fp->cl_id + CNIC_CONTEXT_USE;
 	fp->igu_sb_id = bp->igu_base_sb + fp_idx + CNIC_CONTEXT_USE;
@@ -4562,9 +4562,11 @@ gunzip_nomem1:
 
 static void bnx2x_gunzip_end(struct bnx2x *bp)
 {
-	kfree(bp->strm->workspace);
-	kfree(bp->strm);
-	bp->strm = NULL;
+	if (bp->strm) {
+		kfree(bp->strm->workspace);
+		kfree(bp->strm);
+		bp->strm = NULL;
+	}
 
 	if (bp->gunzip_buf) {
 		dma_free_coherent(&bp->pdev->dev, FW_BUF_SIZE, bp->gunzip_buf,
@@ -5872,9 +5874,6 @@ int bnx2x_init_hw(struct bnx2x *bp, u32 load_code)
 
 	bp->dmae_ready = 0;
 	spin_lock_init(&bp->dmae_lock);
-	rc = bnx2x_gunzip_init(bp);
-	if (rc)
-		return rc;
 
 	switch (load_code) {
 	case FW_MSG_CODE_DRV_LOAD_COMMON:
@@ -5918,80 +5917,10 @@ init_hw_err:
 
 void bnx2x_free_mem(struct bnx2x *bp)
 {
-
-#define BNX2X_PCI_FREE(x, y, size) \
-	do { \
-		if (x) { \
-			dma_free_coherent(&bp->pdev->dev, size, (void *)x, y); \
-			x = NULL; \
-			y = 0; \
-		} \
-	} while (0)
-
-#define BNX2X_FREE(x) \
-	do { \
-		if (x) { \
-			kfree((void *)x); \
-			x = NULL; \
-		} \
-	} while (0)
-
-	int i;
+	bnx2x_gunzip_end(bp);
 
 	/* fastpath */
-	/* Common */
-	for_each_queue(bp, i) {
-#ifdef BCM_CNIC
-		/* FCoE client uses default status block */
-		if (IS_FCOE_IDX(i)) {
-			union host_hc_status_block *sb =
-				&bnx2x_fp(bp, i, status_blk);
-			memset(sb, 0, sizeof(union host_hc_status_block));
-			bnx2x_fp(bp, i, status_blk_mapping) = 0;
-		} else {
-#endif
-		/* status blocks */
-		if (CHIP_IS_E2(bp))
-			BNX2X_PCI_FREE(bnx2x_fp(bp, i, status_blk.e2_sb),
-				       bnx2x_fp(bp, i, status_blk_mapping),
-				       sizeof(struct host_hc_status_block_e2));
-		else
-			BNX2X_PCI_FREE(bnx2x_fp(bp, i, status_blk.e1x_sb),
-				       bnx2x_fp(bp, i, status_blk_mapping),
-				       sizeof(struct host_hc_status_block_e1x));
-#ifdef BCM_CNIC
-		}
-#endif
-	}
-	/* Rx */
-	for_each_rx_queue(bp, i) {
-
-		/* fastpath rx rings: rx_buf rx_desc rx_comp */
-		BNX2X_FREE(bnx2x_fp(bp, i, rx_buf_ring));
-		BNX2X_PCI_FREE(bnx2x_fp(bp, i, rx_desc_ring),
-			       bnx2x_fp(bp, i, rx_desc_mapping),
-			       sizeof(struct eth_rx_bd) * NUM_RX_BD);
-
-		BNX2X_PCI_FREE(bnx2x_fp(bp, i, rx_comp_ring),
-			       bnx2x_fp(bp, i, rx_comp_mapping),
-			       sizeof(struct eth_fast_path_rx_cqe) *
-			       NUM_RCQ_BD);
-
-		/* SGE ring */
-		BNX2X_FREE(bnx2x_fp(bp, i, rx_page_ring));
-		BNX2X_PCI_FREE(bnx2x_fp(bp, i, rx_sge_ring),
-			       bnx2x_fp(bp, i, rx_sge_mapping),
-			       BCM_PAGE_SIZE * NUM_RX_SGE_PAGES);
-	}
-	/* Tx */
-	for_each_tx_queue(bp, i) {
-
-		/* fastpath tx rings: tx_buf tx_desc */
-		BNX2X_FREE(bnx2x_fp(bp, i, tx_buf_ring));
-		BNX2X_PCI_FREE(bnx2x_fp(bp, i, tx_desc_ring),
-			       bnx2x_fp(bp, i, tx_desc_mapping),
-			       sizeof(union eth_tx_bd_types) * NUM_TX_BD);
-	}
+	bnx2x_free_fp_mem(bp);
 	/* end of fastpath */
 
 	BNX2X_PCI_FREE(bp->def_status_blk, bp->def_status_blk_mapping,
@@ -6024,101 +5953,13 @@ void bnx2x_free_mem(struct bnx2x *bp)
 		       BCM_PAGE_SIZE * NUM_EQ_PAGES);
 
 	BNX2X_FREE(bp->rx_indir_table);
-
-#undef BNX2X_PCI_FREE
-#undef BNX2X_KFREE
 }
 
-static inline void set_sb_shortcuts(struct bnx2x *bp, int index)
-{
-	union host_hc_status_block status_blk = bnx2x_fp(bp, index, status_blk);
-	if (CHIP_IS_E2(bp)) {
-		bnx2x_fp(bp, index, sb_index_values) =
-			(__le16 *)status_blk.e2_sb->sb.index_values;
-		bnx2x_fp(bp, index, sb_running_index) =
-			(__le16 *)status_blk.e2_sb->sb.running_index;
-	} else {
-		bnx2x_fp(bp, index, sb_index_values) =
-			(__le16 *)status_blk.e1x_sb->sb.index_values;
-		bnx2x_fp(bp, index, sb_running_index) =
-			(__le16 *)status_blk.e1x_sb->sb.running_index;
-	}
-}
 
 int bnx2x_alloc_mem(struct bnx2x *bp)
 {
-#define BNX2X_PCI_ALLOC(x, y, size) \
-	do { \
-		x = dma_alloc_coherent(&bp->pdev->dev, size, y, GFP_KERNEL); \
-		if (x == NULL) \
-			goto alloc_mem_err; \
-		memset(x, 0, size); \
-	} while (0)
-
-#define BNX2X_ALLOC(x, size) \
-	do { \
-		x = kzalloc(size, GFP_KERNEL); \
-		if (x == NULL) \
-			goto alloc_mem_err; \
-	} while (0)
-
-	int i;
-
-	/* fastpath */
-	/* Common */
-	for_each_queue(bp, i) {
-		union host_hc_status_block *sb = &bnx2x_fp(bp, i, status_blk);
-		bnx2x_fp(bp, i, bp) = bp;
-		/* status blocks */
-#ifdef BCM_CNIC
-		if (!IS_FCOE_IDX(i)) {
-#endif
-			if (CHIP_IS_E2(bp))
-				BNX2X_PCI_ALLOC(sb->e2_sb,
-				    &bnx2x_fp(bp, i, status_blk_mapping),
-				    sizeof(struct host_hc_status_block_e2));
-			else
-				BNX2X_PCI_ALLOC(sb->e1x_sb,
-				    &bnx2x_fp(bp, i, status_blk_mapping),
-				    sizeof(struct host_hc_status_block_e1x));
-#ifdef BCM_CNIC
-		}
-#endif
-		set_sb_shortcuts(bp, i);
-	}
-	/* Rx */
-	for_each_queue(bp, i) {
-
-		/* fastpath rx rings: rx_buf rx_desc rx_comp */
-		BNX2X_ALLOC(bnx2x_fp(bp, i, rx_buf_ring),
-				sizeof(struct sw_rx_bd) * NUM_RX_BD);
-		BNX2X_PCI_ALLOC(bnx2x_fp(bp, i, rx_desc_ring),
-				&bnx2x_fp(bp, i, rx_desc_mapping),
-				sizeof(struct eth_rx_bd) * NUM_RX_BD);
-
-		BNX2X_PCI_ALLOC(bnx2x_fp(bp, i, rx_comp_ring),
-				&bnx2x_fp(bp, i, rx_comp_mapping),
-				sizeof(struct eth_fast_path_rx_cqe) *
-				NUM_RCQ_BD);
-
-		/* SGE ring */
-		BNX2X_ALLOC(bnx2x_fp(bp, i, rx_page_ring),
-				sizeof(struct sw_rx_page) * NUM_RX_SGE);
-		BNX2X_PCI_ALLOC(bnx2x_fp(bp, i, rx_sge_ring),
-				&bnx2x_fp(bp, i, rx_sge_mapping),
-				BCM_PAGE_SIZE * NUM_RX_SGE_PAGES);
-	}
-	/* Tx */
-	for_each_queue(bp, i) {
-
-		/* fastpath tx rings: tx_buf tx_desc */
-		BNX2X_ALLOC(bnx2x_fp(bp, i, tx_buf_ring),
-				sizeof(struct sw_tx_bd) * NUM_TX_BD);
-		BNX2X_PCI_ALLOC(bnx2x_fp(bp, i, tx_desc_ring),
-				&bnx2x_fp(bp, i, tx_desc_mapping),
-				sizeof(union eth_tx_bd_types) * NUM_TX_BD);
-	}
-	/* end of fastpath */
+	if (bnx2x_gunzip_init(bp))
+		return -ENOMEM;
 
 #ifdef BCM_CNIC
 	if (CHIP_IS_E2(bp))
@@ -6158,14 +5999,18 @@ int bnx2x_alloc_mem(struct bnx2x *bp)
 
 	BNX2X_ALLOC(bp->rx_indir_table, sizeof(bp->rx_indir_table[0]) *
 		    TSTORM_INDIRECTION_TABLE_SIZE);
+
+	/* fastpath */
+	/* need to be done at the end, since it's self adjusting to amount
+	 * of memory available for RSS queues
+	 */
+	if (bnx2x_alloc_fp_mem(bp))
+		goto alloc_mem_err;
 	return 0;
 
 alloc_mem_err:
 	bnx2x_free_mem(bp);
 	return -ENOMEM;
-
-#undef BNX2X_PCI_ALLOC
-#undef BNX2X_ALLOC
 }
 
 /*
-- 
1.7.2.2






^ permalink raw reply related

* [net-next v2 6/6] bnx2x: function descriptions format fixed
From: Dmitry Kravkov @ 2011-05-04 22:24 UTC (permalink / raw)
  To: David Miller, netdev@vger.kernel.org; +Cc: Eilon Greenstein

Reported-by: David Miller <davem@davemloft.net>

Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
 drivers/net/bnx2x/bnx2x_cmn.c  |   44 +++---
 drivers/net/bnx2x/bnx2x_cmn.h  |  293 +++++++++++++++++-----------------------
 drivers/net/bnx2x/bnx2x_dcb.c  |   26 ----
 drivers/net/bnx2x/bnx2x_dcb.h  |    6 -
 drivers/net/bnx2x/bnx2x_link.c |   14 +-
 drivers/net/bnx2x/bnx2x_main.c |   60 +++++----
 6 files changed, 184 insertions(+), 259 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c
index 8c16879..e5b3d35 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/bnx2x/bnx2x_cmn.c
@@ -308,13 +308,13 @@ static void bnx2x_tpa_start(struct bnx2x_fastpath *fp, u16 queue,
  */
 #define TPA_TSTAMP_OPT_LEN	12
 /**
- * Calculate the approximate value of the MSS for this
- * aggregation using the first packet of it.
+ * bnx2x_set_lro_mss - calculate the approximate value of the
+ * MSS for this aggregation using the first packet of it.
  *
- * @param bp
- * @param parsing_flags Parsing flags from the START CQE
- * @param len_on_bd Total length of the first packet for the
- *		     aggregation.
+ * @bp:			driver handle
+ * @parsing_flags:	parsing flags from the START CQE
+ * @len_on_bd:		total length of the first packet for the
+ *			aggregation.
  */
 static inline u16 bnx2x_set_lro_mss(struct bnx2x *bp, u16 parsing_flags,
 				    u16 len_on_bd)
@@ -2084,12 +2084,11 @@ static inline void bnx2x_set_pbd_gso_e2(struct sk_buff *skb, u32 *parsing_data,
 }
 
 /**
- * Update PBD in GSO case.
+ * bnx2x_set_pbd_gso - update PBD in GSO case.
  *
- * @param skb
- * @param tx_start_bd
- * @param pbd
- * @param xmit_type
+ * @skb:	packet skb
+ * @pbd:	parse BD
+ * @xmit_type:	xmit flags
  */
 static inline void bnx2x_set_pbd_gso(struct sk_buff *skb,
 				     struct eth_tx_parse_bd_e1x *pbd,
@@ -2116,13 +2115,13 @@ static inline void bnx2x_set_pbd_gso(struct sk_buff *skb,
 }
 
 /**
+ * bnx2x_set_pbd_csum_e2 - update parsing data with checksum for 57712
+ * and return header length
  *
- * @param skb
- * @param tx_start_bd
- * @param pbd_e2
- * @param xmit_type
- *
- * @return header len
+ * @bp:			driver handle
+ * @skb:		packet skb
+ * @parsing_data:	data to be updated
+ * @xmit_type:		xmit flags
  */
 static inline  u8 bnx2x_set_pbd_csum_e2(struct bnx2x *bp, struct sk_buff *skb,
 	u32 *parsing_data, u32 xmit_type)
@@ -2147,13 +2146,12 @@ static inline  u8 bnx2x_set_pbd_csum_e2(struct bnx2x *bp, struct sk_buff *skb,
 }
 
 /**
+ * bnx2x_set_pbd_csum - update PBD with checksum and return header length
  *
- * @param skb
- * @param tx_start_bd
- * @param pbd
- * @param xmit_type
- *
- * @return Header length
+ * @bp:		driver handle
+ * @skb:	packet skb
+ * @pbd:	parse BD to be updated
+ * @xmit_type:	xmit flags
  */
 static inline u8 bnx2x_set_pbd_csum(struct bnx2x *bp, struct sk_buff *skb,
 	struct eth_tx_parse_bd_e1x *pbd,
diff --git a/drivers/net/bnx2x/bnx2x_cmn.h b/drivers/net/bnx2x/bnx2x_cmn.h
index 72f206e..b044e8f 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/bnx2x/bnx2x_cmn.h
@@ -63,43 +63,41 @@ extern int num_queues;
  */
 
 /**
- * Initialize link parameters structure variables.
+ * bnx2x_initial_phy_init - initialize link parameters structure variables.
  *
- * @param bp
- * @param load_mode
- *
- * @return u8
+ * @bp:		driver handle
+ * @load_mode:	current mode
  */
 u8 bnx2x_initial_phy_init(struct bnx2x *bp, int load_mode);
 
 /**
- * Configure hw according to link parameters structure.
+ * bnx2x_link_set - configure hw according to link parameters structure.
  *
- * @param bp
+ * @bp:		driver handle
  */
 void bnx2x_link_set(struct bnx2x *bp);
 
 /**
- * Query link status
+ * bnx2x_link_test - query link status.
  *
- * @param bp
- * @param is_serdes
+ * @bp:		driver handle
+ * @is_serdes:	bool
  *
- * @return 0 - link is UP
+ * Returns 0 if link is UP.
  */
 u8 bnx2x_link_test(struct bnx2x *bp, u8 is_serdes);
 
 /**
- * Handles link status change
+ * bnx2x__link_status_update - handles link status change.
  *
- * @param bp
+ * @bp:		driver handle
  */
 void bnx2x__link_status_update(struct bnx2x *bp);
 
 /**
- * Report link status to upper layer
+ * bnx2x_link_report - report link status to upper layer.
  *
- * @param bp
+ * @bp:		driver handle
  */
 void bnx2x_link_report(struct bnx2x *bp);
 
@@ -107,212 +105,194 @@ void bnx2x_link_report(struct bnx2x *bp);
 void __bnx2x_link_report(struct bnx2x *bp);
 
 /**
- * calculates MF speed according to current linespeed and MF
- * configuration
- *
- * @param bp
+ * bnx2x_get_mf_speed - calculates MF speed according to current
+ * linespeed and MF configuration.
  *
- * @return u16
+ * @bp:		driver handle
  */
 u16 bnx2x_get_mf_speed(struct bnx2x *bp);
 
 /**
- * MSI-X slowpath interrupt handler
+ * bnx2x_msix_sp_int - MSI-X slowpath interrupt handler
  *
- * @param irq
- * @param dev_instance
- *
- * @return irqreturn_t
+ * @irq:		irq number
+ * @dev_instance:	private instance
  */
 irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance);
 
 /**
- * non MSI-X interrupt handler
- *
- * @param irq
- * @param dev_instance
+ * bnx2x_interrupt - non MSI-X interrupt handler
  *
- * @return irqreturn_t
+ * @irq:		irq number
+ * @dev_instance:	private instance
  */
 irqreturn_t bnx2x_interrupt(int irq, void *dev_instance);
 #ifdef BCM_CNIC
 
 /**
- * Send command to cnic driver
+ * bnx2x_cnic_notify - send command to cnic driver
  *
- * @param bp
- * @param cmd
+ * @bp:		driver handle
+ * @cmd:	command
  */
 int bnx2x_cnic_notify(struct bnx2x *bp, int cmd);
 
 /**
- * Provides cnic information for proper interrupt handling
+ * bnx2x_setup_cnic_irq_info - provides cnic information for proper
+ * interrupt handling
  *
- * @param bp
+ * @bp:		driver handle
  */
 void bnx2x_setup_cnic_irq_info(struct bnx2x *bp);
 #endif
 
 /**
- * Enable HW interrupts.
+ * bnx2x_int_enable - enable HW interrupts.
  *
- * @param bp
+ * @bp:		driver handle
  */
 void bnx2x_int_enable(struct bnx2x *bp);
 
 /**
- * Disable interrupts. This function ensures that there are no
- * ISRs or SP DPCs (sp_task) are running after it returns.
+ * bnx2x_int_disable_sync - disable interrupts.
+ *
+ * @bp:		driver handle
+ * @disable_hw:	true, disable HW interrupts.
  *
- * @param bp
- * @param disable_hw if true, disable HW interrupts.
+ * This function ensures that there are no
+ * ISRs or SP DPCs (sp_task) are running after it returns.
  */
 void bnx2x_int_disable_sync(struct bnx2x *bp, int disable_hw);
 
 /**
- * Loads device firmware
- *
- * @param bp
+ * bnx2x_init_firmware - loads device firmware
  *
- * @return int
+ * @bp:		driver handle
  */
 int bnx2x_init_firmware(struct bnx2x *bp);
 
 /**
- * Init HW blocks according to current initialization stage:
+ * bnx2x_init_hw - init HW blocks according to current initialization stage:
  * COMMON, PORT or FUNCTION.
  *
- * @param bp
- * @param load_code: COMMON, PORT or FUNCTION
- *
- * @return int
+ * @bp:		driver handle
+ * @load_code:	COMMON, PORT or FUNCTION
  */
 int bnx2x_init_hw(struct bnx2x *bp, u32 load_code);
 
 /**
- * Init driver internals:
+ * bnx2x_nic_init - init driver internals.
  *  - rings
  *  - status blocks
  *  - etc.
  *
- * @param bp
- * @param load_code COMMON, PORT or FUNCTION
+ * @bp:		driver handle
+ * @load_code:	COMMON, PORT or FUNCTION
  */
 void bnx2x_nic_init(struct bnx2x *bp, u32 load_code);
 
 /**
- * Allocate driver's memory.
- *
- * @param bp
+ * bnx2x_alloc_mem - allocate driver's memory.
  *
- * @return int
+ * @bp:		driver handle
  */
 int bnx2x_alloc_mem(struct bnx2x *bp);
 
 /**
- * Release driver's memory.
+ * bnx2x_free_mem - release driver's memory.
  *
- * @param bp
+ * @bp:		driver handle
  */
 void bnx2x_free_mem(struct bnx2x *bp);
 
 /**
- * Setup eth Client.
+ * bnx2x_setup_client - setup eth client.
  *
- * @param bp
- * @param fp
- * @param is_leading
- *
- * @return int
+ * @bp:		driver handle
+ * @fp:		pointer to fastpath structure
+ * @is_leading:	boolean
  */
 int bnx2x_setup_client(struct bnx2x *bp, struct bnx2x_fastpath *fp,
 		       int is_leading);
 
 /**
- * Set number of queues according to mode
- *
- * @param bp
+ * bnx2x_set_num_queues - set number of queues according to mode.
  *
+ * @bp:		driver handle
  */
 void bnx2x_set_num_queues(struct bnx2x *bp);
 
 /**
- * Cleanup chip internals:
+ * bnx2x_chip_cleanup - cleanup chip internals:
  * - Cleanup MAC configuration.
  * - Close clients.
  * - etc.
  *
- * @param bp
- * @param unload_mode
+ * @bp:			driver handle
+ * @unload_mode:	COMMON, PORT, FUNCTION
  */
 void bnx2x_chip_cleanup(struct bnx2x *bp, int unload_mode);
 
 /**
- * Acquire HW lock.
+ * bnx2x_acquire_hw_lock - acquire HW lock.
  *
- * @param bp
- * @param resource Resource bit which was locked
- *
- * @return int
+ * @bp:		driver handle
+ * @resource:	resource bit which was locked
  */
 int bnx2x_acquire_hw_lock(struct bnx2x *bp, u32 resource);
 
 /**
- * Release HW lock.
- *
- * @param bp driver handle
- * @param resource Resource bit which was locked
+ * bnx2x_release_hw_lock - release HW lock.
  *
- * @return int
+ * @bp:		driver handle
+ * @resource:	resource bit which was locked
  */
 int bnx2x_release_hw_lock(struct bnx2x *bp, u32 resource);
 
 /**
- * Configure eth MAC address in the HW according to the value in
- * netdev->dev_addr.
+ * bnx2x_set_eth_mac - configure eth MAC address in the HW
+ * according to the value in netdev->dev_addr.
  *
- * @param bp driver handle
- * @param set
+ * @bp:		driver handle
+ * @set:	set or clear
  */
 void bnx2x_set_eth_mac(struct bnx2x *bp, int set);
 
 #ifdef BCM_CNIC
 /**
- * Set/Clear FIP MAC(s) at the next enties in the CAM after the ETH
- * MAC(s). This function will wait until the ramdord completion
- * returns.
+ * bnx2x_set_fip_eth_mac_addr - Set/Clear FIP MAC(s) at the next enties
+ * in the CAM after the ETH MAC(s).
  *
- * @param bp driver handle
- * @param set set or clear the CAM entry
+ * @bp:		driver handle
+ * @set:	set or clear the CAM entry
  *
- * @return 0 if cussess, -ENODEV if ramrod doesn't return.
+ * This function will wait until the ramdord completion returns.
+ * Return 0 if cussess, -ENODEV if ramrod doesn't return.
  */
 int bnx2x_set_fip_eth_mac_addr(struct bnx2x *bp, int set);
 
 /**
- * Set/Clear ALL_ENODE mcast MAC.
+ * bnx2x_set_all_enode_macs - Set/Clear ALL_ENODE mcast MAC.
  *
- * @param bp
- * @param set
- *
- * @return int
+ * @bp:		driver handle
+ * @set:	set or clear
  */
 int bnx2x_set_all_enode_macs(struct bnx2x *bp, int set);
 #endif
 
 /**
- * Set MAC filtering configurations.
+ * bnx2x_set_rx_mode - set MAC filtering configurations.
  *
- * @remarks called with netif_tx_lock from dev_mcast.c
+ * @dev:	netdevice
  *
- * @param dev net_device
+ * called with netif_tx_lock from dev_mcast.c
  */
 void bnx2x_set_rx_mode(struct net_device *dev);
 
 /**
- * Configure MAC filtering rules in a FW.
+ * bnx2x_set_storm_rx_mode - configure MAC filtering rules in a FW.
  *
- * @param bp driver handle
+ * @bp:		driver handle
  */
 void bnx2x_set_storm_rx_mode(struct bnx2x *bp);
 
@@ -324,63 +304,60 @@ bool bnx2x_reset_is_done(struct bnx2x *bp);
 void bnx2x_disable_close_the_gate(struct bnx2x *bp);
 
 /**
- * Perform statistics handling according to event
+ * bnx2x_stats_handle - perform statistics handling according to event.
  *
- * @param bp driver handle
- * @param event bnx2x_stats_event
+ * @bp:		driver handle
+ * @event:	bnx2x_stats_event
  */
 void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event);
 
 /**
- * Handle ramrods completion
+ * bnx2x_sp_event - handle ramrods completion
  *
- * @param fp fastpath handle for the event
- * @param rr_cqe eth_rx_cqe
+ * @fp:		fastpath handle for the event
+ * @rr_cqe:	eth_rx_cqe
  */
 void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe);
 
 /**
- * Init/halt function before/after sending
+ * bnx2x_func_start - Init/halt function before/after sending
  * CLIENT_SETUP/CFC_DEL for the first/last client.
  *
- * @param bp
- *
- * @return int
+ * @bp:		driver handle
  */
 int bnx2x_func_start(struct bnx2x *bp);
 
 /**
- * Prepare ILT configurations according to current driver
+ * bnx2x_ilt_set_info - prepare ILT configurations according to current driver
  * parameters.
  *
- * @param bp
+ * @bp:		driver handle
  */
 void bnx2x_ilt_set_info(struct bnx2x *bp);
 
 /**
- * Inintialize dcbx protocol
+ * bnx2x_dcbx_init - initialize dcbx protocol
  *
- * @param bp
+ * @bp:		driver handle
  */
 void bnx2x_dcbx_init(struct bnx2x *bp);
 
 /**
- * Set power state to the requested value. Currently only D0 and
- * D3hot are supported.
+ * bnx2x_set_power_state - set power state to the requested value.
  *
- * @param bp
- * @param state D0 or D3hot
+ * @bp:		driver handle
+ * @state:	required state D0 or D3hot
  *
- * @return int
+ * Currently only D0 and D3hot are supported.
  */
 int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state);
 
 /**
- * Updates MAX part of MF configuration in HW
+ * bnx2x_update_max_mf_config - update MAX part of MF configuration in HW
  * (if required)
  *
- * @param bp
- * @param value
+ * @bp:		driver handle
+ * @value:	new value
  */
 void bnx2x_update_max_mf_config(struct bnx2x *bp, u32 value);
 
@@ -420,51 +397,49 @@ void bnx2x_netif_stop(struct bnx2x *bp, int disable_hw);
 void bnx2x_netif_start(struct bnx2x *bp);
 
 /**
- * Fill msix_table, request vectors, update num_queues according
- * to number of available vectors
+ * bnx2x_enable_msix -fill msix_table, request vectors, update num_queues
+ * according to number of available vectors
  *
- * @param bp
- *
- * @return int
+ * @bp:		driver handle
  */
 int bnx2x_enable_msix(struct bnx2x *bp);
 
 /**
- * Request msi mode from OS, updated internals accordingly
- *
- * @param bp
+ * bnx2x_enable_msi - request msi mode from OS, updated internals accordingly
  *
- * @return int
+ * @bp:		driver handle
  */
 int bnx2x_enable_msi(struct bnx2x *bp);
 
 /**
- * NAPI callback
+ * bnx2x_poll - NAPI callback
  *
- * @param napi
- * @param budget
+ * @napi:	napi structure
+ * @budget:
  *
- * @return int
  */
 int bnx2x_poll(struct napi_struct *napi, int budget);
 
 /**
- * Allocate/release memories outsize main driver structure
+ * bnx2x_alloc_mem_bp - allocate memories outsize main driver structure
  *
- * @param bp
- *
- * @return int
+ * @bp:		driver handle
  */
 int __devinit bnx2x_alloc_mem_bp(struct bnx2x *bp);
+
+/**
+ * bnx2x_free_mem_bp - release memories outsize main driver structure
+ *
+ * @bp:		driver handle
+ */
 void bnx2x_free_mem_bp(struct bnx2x *bp);
 
 /**
- * Change mtu netdev callback
+ * bnx2x_change_mtu - change mtu netdev callback
  *
- * @param dev
- * @param new_mtu
+ * @dev:	net device
+ * @new_mtu:	requested mtu
  *
- * @return int
  */
 int bnx2x_change_mtu(struct net_device *dev, int new_mtu);
 
@@ -472,29 +447,12 @@ u32 bnx2x_fix_features(struct net_device *dev, u32 features);
 int bnx2x_set_features(struct net_device *dev, u32 features);
 
 /**
- * tx timeout netdev callback
- *
- * @param dev
- * @param new_mtu
+ * bnx2x_tx_timeout - tx timeout netdev callback
  *
- * @return int
+ * @dev:	net device
  */
 void bnx2x_tx_timeout(struct net_device *dev);
 
-#ifdef BCM_VLAN
-/**
- * vlan rx register netdev callback
- *
- * @param dev
- * @param new_mtu
- *
- * @return int
- */
-void bnx2x_vlan_rx_register(struct net_device *dev,
-				   struct vlan_group *vlgrp);
-
-#endif
-
 static inline void bnx2x_update_fpsb_idx(struct bnx2x_fastpath *fp)
 {
 	barrier(); /* status block is written to by the chip */
@@ -745,7 +703,7 @@ static inline int bnx2x_has_rx_work(struct bnx2x_fastpath *fp)
 /**
  * disables tx from stack point of view
  *
- * @param bp
+ * @bp:		driver handle
  */
 static inline void bnx2x_tx_disable(struct bnx2x *bp)
 {
@@ -1149,12 +1107,11 @@ void bnx2x_acquire_phy_lock(struct bnx2x *bp);
 void bnx2x_release_phy_lock(struct bnx2x *bp);
 
 /**
- * Extracts MAX BW part from MF configuration.
+ * bnx2x_extract_max_cfg - extract MAX BW part from MF configuration.
  *
- * @param bp
- * @param mf_cfg
+ * @bp:		driver handle
+ * @mf_cfg:	MF configuration
  *
- * @return u16
  */
 static inline u16 bnx2x_extract_max_cfg(struct bnx2x *bp, u32 mf_cfg)
 {
diff --git a/drivers/net/bnx2x/bnx2x_dcb.c b/drivers/net/bnx2x/bnx2x_dcb.c
index 3396ff2..0f83092 100644
--- a/drivers/net/bnx2x/bnx2x_dcb.c
+++ b/drivers/net/bnx2x/bnx2x_dcb.c
@@ -1079,12 +1079,6 @@ static void bnx2x_dcbx_get_num_pg_traf_type(struct bnx2x *bp,
 	}
 }
 
-
-/*******************************************************************************
- * Description: single priority group
- *
- * Return:
- ******************************************************************************/
 static void bnx2x_dcbx_ets_disabled_entry_data(struct bnx2x *bp,
 					       struct cos_help_data *cos_data,
 					       u32 pri_join_mask)
@@ -1097,11 +1091,6 @@ static void bnx2x_dcbx_ets_disabled_entry_data(struct bnx2x *bp,
 	cos_data->num_of_cos = 1;
 }
 
-/*******************************************************************************
- * Description: updating the cos bw
- *
- * Return:
- ******************************************************************************/
 static inline void bnx2x_dcbx_add_to_cos_bw(struct bnx2x *bp,
 					    struct cos_entry_help_data *data,
 					    u8 pg_bw)
@@ -1112,11 +1101,6 @@ static inline void bnx2x_dcbx_add_to_cos_bw(struct bnx2x *bp,
 		data->cos_bw += pg_bw;
 }
 
-/*******************************************************************************
- * Description: single priority group
- *
- * Return:
- ******************************************************************************/
 static void bnx2x_dcbx_separate_pauseable_from_non(struct bnx2x *bp,
 			struct cos_help_data *cos_data,
 			u32 *pg_pri_orginal_spread,
@@ -1369,11 +1353,6 @@ static void bnx2x_dcbx_two_pg_to_cos_params(
 	}
 }
 
-/*******************************************************************************
- * Description: Still
- *
- * Return:
- ******************************************************************************/
 static void bnx2x_dcbx_three_pg_to_cos_params(
 			      struct bnx2x		*bp,
 			      struct pg_help_data	*pg_help_data,
@@ -1561,11 +1540,6 @@ static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x *bp,
 	}
 }
 
-/*******************************************************************************
- * Description: Fill pfc_config struct that will be sent in DCBX start ramrod
- *
- * Return:
- ******************************************************************************/
 static void bnx2x_pfc_fw_struct_e2(struct bnx2x *bp)
 {
 	struct flow_control_configuration   *pfc_fw_cfg = NULL;
diff --git a/drivers/net/bnx2x/bnx2x_dcb.h b/drivers/net/bnx2x/bnx2x_dcb.h
index bb6e9a5b..bed369d 100644
--- a/drivers/net/bnx2x/bnx2x_dcb.h
+++ b/drivers/net/bnx2x/bnx2x_dcb.h
@@ -61,9 +61,6 @@ struct bnx2x_dcbx_port_params {
 #define BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE		1
 #define BNX2X_DCBX_OVERWRITE_SETTINGS_INVALID	(BNX2X_DCBX_CONFIG_INV_VALUE)
 
-/*******************************************************************************
- * LLDP protocol configuration parameters.
- ******************************************************************************/
 struct bnx2x_config_lldp_params {
 	u32 overwrite_settings;
 	u32 msg_tx_hold;
@@ -83,9 +80,6 @@ struct bnx2x_admin_priority_app_table {
 		u32 app_id;
 };
 
-/*******************************************************************************
- * DCBX protocol configuration parameters.
- ******************************************************************************/
 struct bnx2x_config_dcbx_params {
 	u32 overwrite_settings;
 	u32 admin_dcbx_version;
diff --git a/drivers/net/bnx2x/bnx2x_link.c b/drivers/net/bnx2x/bnx2x_link.c
index 974ef2b..076e11f 100644
--- a/drivers/net/bnx2x/bnx2x_link.c
+++ b/drivers/net/bnx2x/bnx2x_link.c
@@ -385,7 +385,7 @@ u8 bnx2x_ets_strict(const struct link_params *params, const u8 strict_cos)
 	return 0;
 }
 /******************************************************************/
-/*			ETS section				  */
+/*			PFC section				  */
 /******************************************************************/
 
 static void bnx2x_bmac2_get_pfc_stat(struct link_params *params,
@@ -1301,14 +1301,12 @@ static u8 bnx2x_pbf_update(struct link_params *params, u32 flow_ctrl,
 	return 0;
 }
 
-/*
- * get_emac_base
- *
- * @param cb
- * @param mdc_mdio_access
- * @param port
+/**
+ * bnx2x_get_emac_base - retrive emac base address
  *
- * @return u32
+ * @bp:			driver handle
+ * @mdc_mdio_access:	access type
+ * @port:		port id
  *
  * This function selects the MDC/MDIO access (through emac0 or
  * emac1) depend on the mdc_mdio_access, port, port swapped. Each
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index 0c31b91..d6aa25e 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -6035,14 +6035,15 @@ static int bnx2x_func_stop(struct bnx2x *bp)
 }
 
 /**
- * Sets a MAC in a CAM for a few L2 Clients for E1x chips
+ * bnx2x_set_mac_addr_gen - set a MAC in a CAM for a few L2 Clients
+ * for E1x chips
  *
- * @param bp driver descriptor
- * @param set set or clear an entry (1 or 0)
- * @param mac pointer to a buffer containing a MAC
- * @param cl_bit_vec bit vector of clients to register a MAC for
- * @param cam_offset offset in a CAM to use
- * @param is_bcast is the set MAC a broadcast address (for E1 only)
+ * @bp:		driver handle
+ * @set:	set or clear an entry (1 or 0)
+ * @mac:	pointer to a buffer containing a MAC
+ * @cl_bit_vec:	bit vector of clients to register a MAC for
+ * @cam_offset:	offset in a CAM to use
+ * @is_bcast:	is the set MAC a broadcast address (for E1 only)
  */
 static void bnx2x_set_mac_addr_gen(struct bnx2x *bp, int set, const u8 *mac,
 				   u32 cl_bit_vec, u8 cam_offset,
@@ -6402,14 +6403,14 @@ void bnx2x_invalidate_e1h_mc_list(struct bnx2x *bp)
 
 #ifdef BCM_CNIC
 /**
- * Set iSCSI MAC(s) at the next enties in the CAM after the ETH
- * MAC(s). This function will wait until the ramdord completion
- * returns.
+ * bnx2x_set_iscsi_eth_mac_addr - set iSCSI MAC(s) at the next
+ * enties in the CAM after the ETH MAC(s).
  *
- * @param bp driver handle
- * @param set set or clear the CAM entry
+ * @bp:		driver handle
+ * @set:	set or clear the CAM entry
  *
- * @return 0 if cussess, -ENODEV if ramrod doesn't return.
+ * This function will wait until the ramdord completion returns.
+ * Return 0 if success, -ENODEV if ramrod doesn't return.
  */
 static int bnx2x_set_iscsi_eth_mac_addr(struct bnx2x *bp, int set)
 {
@@ -6430,14 +6431,14 @@ static int bnx2x_set_iscsi_eth_mac_addr(struct bnx2x *bp, int set)
 }
 
 /**
- * Set FCoE L2 MAC(s) at the next enties in the CAM after the
- * ETH MAC(s). This function will wait until the ramdord
- * completion returns.
+ * bnx2x_set_fip_eth_mac_addr - set FCoE L2 MAC(s) at the next enties
+ * in the CAM after the ETH MAC(s).
  *
- * @param bp driver handle
- * @param set set or clear the CAM entry
+ * @bp:		driver handle
+ * @set:	set or clear the CAM entry
  *
- * @return 0 if cussess, -ENODEV if ramrod doesn't return.
+ * This function will wait until the ramrod completion returns.
+ * Returns 0 if success, -ENODEV if ramrod doesn't return.
  */
 int bnx2x_set_fip_eth_mac_addr(struct bnx2x *bp, int set)
 {
@@ -6641,12 +6642,12 @@ static int bnx2x_setup_fw_client(struct bnx2x *bp,
 }
 
 /**
- * Configure interrupt mode according to current configuration.
- * In case of MSI-X it will also try to enable MSI-X.
+ * bnx2x_set_int_mode - configure interrupt mode according to
+ * current configuration.
  *
- * @param bp
+ * @bp:		driver handle
  *
- * @return int
+ * In case of MSI-X it will also try to enable MSI-X.
  */
 static int __devinit bnx2x_set_int_mode(struct bnx2x *bp)
 {
@@ -7244,10 +7245,12 @@ static void bnx2x_clp_reset_done(struct bnx2x *bp, u32 magic_val)
 }
 
 /**
- * Prepares for MCP reset: takes care of CLP configurations.
+ * bnx2x_reset_mcp_prep - prepare for MCP reset.
  *
- * @param bp
- * @param magic_val Old value of 'magic' bit.
+ * @bp:		driver handle
+ * @magic_val:	old value of 'magic' bit.
+ *
+ * Takes care of CLP configurations.
  */
 static void bnx2x_reset_mcp_prep(struct bnx2x *bp, u32 *magic_val)
 {
@@ -7272,10 +7275,11 @@ static void bnx2x_reset_mcp_prep(struct bnx2x *bp, u32 *magic_val)
 #define MCP_TIMEOUT      5000   /* 5 seconds (in ms) */
 #define MCP_ONE_TIMEOUT  100    /* 100 ms */
 
-/* Waits for MCP_ONE_TIMEOUT or MCP_ONE_TIMEOUT*10,
+/**
+ * bnx2x_mcp_wait_one - wait for MCP_ONE_TIMEOUT or MCP_ONE_TIMEOUT*10,
  * depending on the HW type.
  *
- * @param bp
+ * @bp:	driver handle
  */
 static inline void bnx2x_mcp_wait_one(struct bnx2x *bp)
 {
-- 
1.7.2.2






^ permalink raw reply related

* [net-next v2 2/6] bnx2x: allow WoL on every function in MF modes
From: Dmitry Kravkov @ 2011-05-04 22:22 UTC (permalink / raw)
  To: davem, netdev@vger.kernel.org; +Cc: Eilon Greenstein


Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
 drivers/net/bnx2x/bnx2x_main.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index bc847b1..259d1d9 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -8063,13 +8063,9 @@ static void __devinit bnx2x_get_common_hwinfo(struct bnx2x *bp)
 		(val >= REQ_BC_VER_4_VRFY_SPECIFIC_PHY_OPT_MDL) ?
 		FEATURE_CONFIG_BC_SUPPORTS_DUAL_PHY_OPT_MDL_VRFY : 0;
 
-	if (BP_E1HVN(bp) == 0) {
-		pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_PMC, &pmc);
-		bp->flags |= (pmc & PCI_PM_CAP_PME_D3cold) ? 0 : NO_WOL_FLAG;
-	} else {
-		/* no WOL capability for E1HVN != 0 */
-		bp->flags |= NO_WOL_FLAG;
-	}
+	pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_PMC, &pmc);
+	bp->flags |= (pmc & PCI_PM_CAP_PME_D3cold) ? 0 : NO_WOL_FLAG;
+
 	BNX2X_DEV_INFO("%sWoL capable\n",
 		       (bp->flags & NO_WOL_FLAG) ? "not " : "");
 
-- 
1.7.2.2






^ permalink raw reply related

* [net-next v2 3/6] bnx2x: Do storage mac address validation for SF mode.
From: Dmitry Kravkov @ 2011-05-04 22:23 UTC (permalink / raw)
  To: netdev@vger.kernel.org, David Miller; +Cc: Eilon Greenstein

Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
 drivers/net/bnx2x/bnx2x_main.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index 259d1d9..32f9f7f 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -8571,15 +8571,6 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp)
 				BNX2X_DEV_INFO("Read iSCSI MAC: "
 					       "0x%x:0x%04x\n", val2, val);
 				bnx2x_set_mac_buf(iscsi_mac, val, val2);
-
-				/* Disable iSCSI OOO if MAC configuration is
-				 * invalid.
-				 */
-				if (!is_valid_ether_addr(iscsi_mac)) {
-					bp->flags |= NO_ISCSI_OOO_FLAG |
-						     NO_ISCSI_FLAG;
-					memset(iscsi_mac, 0, ETH_ALEN);
-				}
 			} else
 				bp->flags |= NO_ISCSI_OOO_FLAG | NO_ISCSI_FLAG;
 
@@ -8592,13 +8583,6 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp)
 					       "0x%x:0x%04x\n", val2, val);
 				bnx2x_set_mac_buf(fip_mac, val, val2);
 
-				/* Disable FCoE if MAC configuration is
-				 * invalid.
-				 */
-				if (!is_valid_ether_addr(fip_mac)) {
-					bp->flags |= NO_FCOE_FLAG;
-					memset(bp->fip_mac, 0, ETH_ALEN);
-				}
 			} else
 				bp->flags |= NO_FCOE_FLAG;
 		}
@@ -8629,6 +8613,22 @@ static void __devinit bnx2x_get_mac_hwinfo(struct bnx2x *bp)
 		else if (!IS_MF(bp))
 			memcpy(fip_mac, iscsi_mac, ETH_ALEN);
 	}
+
+	/* Disable iSCSI if MAC configuration is
+	 * invalid.
+	 */
+	if (!is_valid_ether_addr(iscsi_mac)) {
+		bp->flags |= NO_ISCSI_FLAG;
+		memset(iscsi_mac, 0, ETH_ALEN);
+	}
+
+	/* Disable FCoE if MAC configuration is
+	 * invalid.
+	 */
+	if (!is_valid_ether_addr(fip_mac)) {
+		bp->flags |= NO_FCOE_FLAG;
+		memset(bp->fip_mac, 0, ETH_ALEN);
+	}
 #endif
 }
 
-- 
1.7.2.2






^ permalink raw reply related

* Re: tap/bridge: Dropping NETIF_F_GSO/NETIF_F_SG
From: Herbert Xu @ 2011-05-04 22:34 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Michał Mirosław, netdev, Ben Hutchings
In-Reply-To: <20110504181813.GA17547@redhat.com>

On Wed, May 04, 2011 at 09:18:14PM +0300, Michael S. Tsirkin wrote:
> BTW, I just noticed that net-next spits out
> many of the following when I run any VMs:
> 
> tap0: Dropping NETIF_F_SG since no checksum feature.
> tap0: Dropping NETIF_F_GSO since no SG feature.
> tap0: Features changed: 0x401b4849 -> 0x40004040
> device msttap0 entered promiscuous mode
> br0: Dropping NETIF_F_GSO since no SG feature.
> br0: port 1(msttap0) entering forwarding state
> br0: port 1(msttap0) entering forwarding state
> tap0: Features changed: 0x40004040 -> 0x40024849
> tap0: Dropping NETIF_F_SG since no checksum feature.
> tap0: Dropping NETIF_F_GSO since no SG feature.
> tap0: Features changed: 0x40024849 -> 0x40004040
> br0: Dropping NETIF_F_GSO since no SG feature.
> tap0: Dropping NETIF_F_SG since no checksum feature.
> tap0: Dropping NETIF_F_GSO since no SG feature.
> tap0: Dropping NETIF_F_SG since no checksum feature.
> tap0: Dropping NETIF_F_GSO since no SG feature.
> tap0: Dropping NETIF_F_SG since no checksum feature.
> tap0: Dropping NETIF_F_GSO since no SG feature.
> tap0: Dropping NETIF_F_SG since no checksum feature.
> tap0: Dropping NETIF_F_GSO since no SG feature.
> tap0: Features changed: 0x40004040 -> 0x401b4849
> tap0: Dropping NETIF_F_SG since no checksum feature.
> tap0: Dropping NETIF_F_GSO since no SG feature.
> tap0: Features changed: 0x401b4849 -> 0x40004040
> br0: Dropping NETIF_F_GSO since no SG feature.
> 
> My problem is not primarily with warnings:
> 
> will that linearize all packets and disable GSO
> for tap and bridge? If yes it can't be good
> for performance...

I think so.  So the question is why is checksum off?

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply

* Re: [PATCH] net/bonding: bonding: Adjust coding style for bond_3ad files.
From: Joe Perches @ 2011-05-04 22:46 UTC (permalink / raw)
  To: Rafael Azenha Aquini
  Cc: kernel-janitors.vger.kernel.org, Jay Vosburgh, Andy Gospodarek,
	netdev
In-Reply-To: <20110504221844.GA17955@x61.tchesoft.com>

On Wed, 2011-05-04 at 19:18 -0300, Rafael Azenha Aquini wrote:
> I did some mods there, in an attempt to make that code stick as
> closely as possible with the Kernel coding style.
> Signed-off-by: Rafael Aquini <aquini@linux.com>
>  drivers/net/bonding/bond_3ad.c |  918 +++++++++++++++++++++++-----------------
>  drivers/net/bonding/bond_3ad.h |  189 +++++----
> diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
> index 31912f1..97e7528 100644
> --- a/drivers/net/bonding/bond_3ad.c
> +++ b/drivers/net/bonding/bond_3ad.c
[]
> @@ -59,7 +59,10 @@
>  #define AD_STATE_DEFAULTED       0x40
>  #define AD_STATE_EXPIRED         0x80
>  
> -// Port Variables definitions used by the State Machines(43.4.7 in the 802.3ad standard)
> +/*
> + * Port Variables definitions used by the State
> + * Machines (43.4.7 in the 802.3ad standard)
> + */

If you're going to reflow comments, please try to keep
operational phrases on the same line.  Something like

/*
 * Port Variables definitions used by the State Machines
 * (43.4.7 in the 802.3ad standard)
 */

btw: David Miller, the drivers/net maintainer prefers
comments to start on the same opening line as the comment
initiator like this:

/* Port Variables definitions used by the State Machines
 * (43.4.7 in the 802.3ad standard)
 */

[]

> -// compare MAC addresses
>  #define MAC_ADDRESS_COMPARE(A, B) memcmp(A, B, ETH_ALEN)

You could convert all uses of this macro to compare_ether_addr
and delete this macro.

>  static struct mac_addr null_mac_addr = { { 0, 0, 0, 0, 0, 0 } };

const

> @@ -113,14 +115,12 @@ static void ad_initialize_agg(struct aggregator *aggregator);
>  static void ad_initialize_port(struct port *port, int lacp_fast);
>  static void ad_enable_collecting_distributing(struct port *port);
>  static void ad_disable_collecting_distributing(struct port *port);
> -static void ad_marker_info_received(struct bond_marker *marker_info, struct port *port);
> -static void ad_marker_response_received(struct bond_marker *marker, struct port *port);
> -
> -
> -/////////////////////////////////////////////////////////////////////////////////
> -// ================= api to bonding and kernel code ==================
> -/////////////////////////////////////////////////////////////////////////////////
> +static void ad_marker_info_received(struct bond_marker *marker_info,
> +							struct port *port);

Better to use either of these forms.

Args aligned to open parenthesis:

static void ad_marker_info_received(struct bond_marker *marker_info,
				    struct port *port);

Return type on separate line:

static void
ad_marker_info_received(struct bond_marker *marker_info, struct port *port);

In any case, please align all additional args to the open parenthesis.

> @@ -161,7 +161,6 @@ static inline struct port *__get_next_port(struct port *port)
>  	struct bonding *bond = __get_bond_by_port(port);
>  	struct slave *slave = port->slave;
>  
> -	// If there's no bond for this port, or this is the last slave

I think these comments are non-obvious enough to leave.

> @@ -365,22 +365,26 @@ static u8 __get_duplex(struct port *port)
>  
>  	u8 retval;
>  
> -	//  handling a special case: when the configuration starts with
> -	// link down, it sets the duplex to 0.
> +	/*
> +	 * handling a special case: when the configuration starts with
> +	 * link down, it sets the duplex to 0.
> +	 */

	/* handling a special case:
	 * When the configuration starts with link down, it sets the duplex to 0
	 */

>  	if (slave->link != BOND_LINK_UP)
>  		retval = 0x0;
>  	else {
>  		switch (slave->duplex) {
>  		case DUPLEX_FULL:
>  			retval = 0x1;
> -			pr_debug("Port %d Received status full duplex update from adapter\n",
> -				 port->actor_port_number);
> +			pr_debug("Port %d Received status "
> +					"full duplex update from adapter\n",
> +					port->actor_port_number);

Don't reflow format strings.
These aren't errors and are preferred for easier grep.

> @@ -394,12 +398,9 @@ static u8 __get_duplex(struct port *port)
>   */
>  static inline void __initialize_port_locks(struct port *port)
>  {
> -	// make sure it isn't called twice
>  	spin_lock_init(&(SLAVE_AD_INFO(port->slave).state_machine_lock));
>  }

Lost comment?

[]

> @@ -466,17 +463,17 @@ static u16 __ad_timer_to_ticks(u16 timer_type, u16 par)
>   */
>  static void __choose_matched(struct lacpdu *lacpdu, struct port *port)
>  {
> -	// check if all parameters are alike
>  	if (((ntohs(lacpdu->partner_port) == port->actor_port_number) &&
> -	     (ntohs(lacpdu->partner_port_priority) == port->actor_port_priority) &&
> -	     !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) &&
> -	     (ntohs(lacpdu->partner_system_priority) == port->actor_system_priority) &&
> -	     (ntohs(lacpdu->partner_key) == port->actor_oper_port_key) &&
> -	     ((lacpdu->partner_state & AD_STATE_AGGREGATION) == (port->actor_oper_port_state & AD_STATE_AGGREGATION))) ||
> -	    // or this is individual link(aggregation == FALSE)
> -	    ((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0)
> -		) {
> -		// update the state machine Matched variable
> +	     (ntohs(lacpdu->partner_port_priority) == port->actor_port_priority)
> +	    && !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system),
> +							&(port->actor_system))
> +	    && (ntohs(lacpdu->partner_system_priority) ==
> +						   port->actor_system_priority)
> +	    && (ntohs(lacpdu->partner_key) == port->actor_oper_port_key)
> +	    && ((lacpdu->partner_state & AD_STATE_AGGREGATION) ==
> +			(port->actor_oper_port_state & AD_STATE_AGGREGATION)))
> +	    || ((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0)) {
> +		/* update the state machine Selected variable */

Not an improvement.

Logical continuations are put at the EOL.
If these are longer than 80 char, I'd ignore them.

> -		// set the partner sync. to on if the partner is sync. and the port is matched
> +		/* switch on partner sync. if partner is synchronized,
> +		 * and the port is matched
> +		 */

I think the original text better.

> @@ -675,7 +673,9 @@ static int __agg_ports_are_ready(struct aggregator *aggregator)
>  	int retval = 1;
>  
>  	if (aggregator) {
> -		// scan all ports in this aggregator to verfy if they are all ready
> +		/* scan all ports in this aggregator to verfy
> +		 * if they are all ready
> +		 */

verify.

For the rest, too long, didn't read...


^ permalink raw reply

* Re: [net-next v2 1/6] bnx2x: link report improvements
From: Ben Hutchings @ 2011-05-04 22:48 UTC (permalink / raw)
  To: dmitry; +Cc: davem, netdev@vger.kernel.org, Eilon Greenstein,
	Vladislav Zolotarov
In-Reply-To: <1304547764.19742.17.camel@lb-tlvb-dmitry>

On Thu, 2011-05-05 at 01:22 +0300, Dmitry Kravkov wrote:
> From: Vladislav Zolotarov <vladz@broadcom.com>
> 
> To avoid link notification duplication
[...]
> --- a/drivers/net/bnx2x/bnx2x_cmn.c
> +++ b/drivers/net/bnx2x/bnx2x_cmn.c
> @@ -758,35 +758,120 @@ u16 bnx2x_get_mf_speed(struct bnx2x *bp)
>  	return line_speed;
>  }
>  
> +/**
> + * bnx2x_fill_report_data - fill Link report data according to the current link
> + * configuration.

The kernel-doc format doesn't allow for continuation lines like this.
The short description has to fit on one physical line along with the
function or type name.

Ben.

> + * @bp:		driver handle
> + * @data:	link state to update
> + *
> + * It uses a none-atomic bit operations because is called under the mutex.
> + */
[...]

-- 
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


^ permalink raw reply

* [PATCH] ehea: fix wrongly reported speed and port
From: Kleber Sacilotto de Souza @ 2011-05-04 23:05 UTC (permalink / raw)
  To: Breno Leitao; +Cc: netdev@vger.kernel.org

Currently EHEA reports to ethtool as supporting 10M, 100M, 1G and
10G and connected to FIBRE independent of the hardware configuration.
However, when connected to FIBRE the only supported speed is 10G
full-duplex, and the other speeds and modes are only supported
when connected to twisted pair.

Signed-off-by: Kleber Sacilotto de Souza <klebers@linux.vnet.ibm.com>
---
 drivers/net/ehea/ehea_ethtool.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ehea/ehea_ethtool.c b/drivers/net/ehea/ehea_ethtool.c
index 3e2e734..f3bbdce 100644
--- a/drivers/net/ehea/ehea_ethtool.c
+++ b/drivers/net/ehea/ehea_ethtool.c
@@ -55,15 +55,20 @@ static int ehea_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 		cmd->duplex = -1;
 	}

-	cmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_1000baseT_Full
-		       | SUPPORTED_100baseT_Full |  SUPPORTED_100baseT_Half
-		       | SUPPORTED_10baseT_Full | SUPPORTED_10baseT_Half
-		       | SUPPORTED_Autoneg | SUPPORTED_FIBRE);
-
-	cmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_Autoneg
-			 | ADVERTISED_FIBRE);
+	if (cmd->speed == SPEED_10000) {
+		cmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
+		cmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE);
+		cmd->port = PORT_FIBRE;
+	} else {
+		cmd->supported = (SUPPORTED_1000baseT_Full | SUPPORTED_100baseT_Full
+			       | SUPPORTED_100baseT_Half | SUPPORTED_10baseT_Full
+			       | SUPPORTED_10baseT_Half | SUPPORTED_Autoneg
+			       | SUPPORTED_TP);
+		cmd->advertising = (ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg
+				 | ADVERTISED_TP);
+		cmd->port = PORT_TP;
+	}

-	cmd->port = PORT_FIBRE;
 	cmd->autoneg = port->autoneg == 1 ? AUTONEG_ENABLE : AUTONEG_DISABLE;

 	return 0;
-- 
1.7.1




^ permalink raw reply related

* Re: tap/bridge: Dropping NETIF_F_GSO/NETIF_F_SG
From: Michał Mirosław @ 2011-05-04 23:28 UTC (permalink / raw)
  To: Herbert Xu; +Cc: Michael S. Tsirkin, netdev, Ben Hutchings
In-Reply-To: <20110504223415.GA14819@gondor.apana.org.au>

On Thu, May 05, 2011 at 08:34:15AM +1000, Herbert Xu wrote:
> On Wed, May 04, 2011 at 09:18:14PM +0300, Michael S. Tsirkin wrote:
> > BTW, I just noticed that net-next spits out
> > many of the following when I run any VMs:
> > 
> > tap0: Dropping NETIF_F_SG since no checksum feature.
> > tap0: Dropping NETIF_F_GSO since no SG feature.
> > tap0: Features changed: 0x401b4849 -> 0x40004040
> > device msttap0 entered promiscuous mode
> > br0: Dropping NETIF_F_GSO since no SG feature.
> > br0: port 1(msttap0) entering forwarding state
> > br0: port 1(msttap0) entering forwarding state
> > tap0: Features changed: 0x40004040 -> 0x40024849
> > tap0: Dropping NETIF_F_SG since no checksum feature.
> > tap0: Dropping NETIF_F_GSO since no SG feature.
> > tap0: Features changed: 0x40024849 -> 0x40004040
> > br0: Dropping NETIF_F_GSO since no SG feature.
> > tap0: Dropping NETIF_F_SG since no checksum feature.
> > tap0: Dropping NETIF_F_GSO since no SG feature.
> > tap0: Dropping NETIF_F_SG since no checksum feature.
> > tap0: Dropping NETIF_F_GSO since no SG feature.
> > tap0: Dropping NETIF_F_SG since no checksum feature.
> > tap0: Dropping NETIF_F_GSO since no SG feature.
> > tap0: Dropping NETIF_F_SG since no checksum feature.
> > tap0: Dropping NETIF_F_GSO since no SG feature.
> > tap0: Features changed: 0x40004040 -> 0x401b4849
> > tap0: Dropping NETIF_F_SG since no checksum feature.
> > tap0: Dropping NETIF_F_GSO since no SG feature.
> > tap0: Features changed: 0x401b4849 -> 0x40004040
> > br0: Dropping NETIF_F_GSO since no SG feature.
> > 
> > My problem is not primarily with warnings:
> > 
> > will that linearize all packets and disable GSO
> > for tap and bridge? If yes it can't be good
> > for performance...
> I think so.  So the question is why is checksum off?

Whatever application is creating the tap0 device is not calling
ioctl(TUNSETOFFLOAD) with TUN_F_CSUM set. This is userspace bug/feature
exposed by recent changes to netdev features handling.

Best Regards,
Michał Mirosław

^ permalink raw reply

* Re: [PATCH] net/bonding: bonding: Adjust coding style for bond_3ad files.
From: Stephen Hemminger @ 2011-05-04 23:38 UTC (permalink / raw)
  To: Rafael Azenha Aquini
  Cc: kernel-janitors.vger.kernel.org, Jay Vosburgh, Andy Gospodarek,
	netdev
In-Reply-To: <20110504221844.GA17955@x61.tchesoft.com>

On Wed, 4 May 2011 19:18:47 -0300
Rafael Azenha Aquini <aquini@linux.com> wrote:

>  
> -// compare MAC addresses
>  #define MAC_ADDRESS_COMPARE(A, B) memcmp(A, B, ETH_ALEN)
>  
>  static struct mac_addr null_mac_addr = { { 0, 0, 0, 0, 0, 0 } };

These should be changed to use compare_ether_addr and is_zero_ether_addr
routines in etherdevice.h

-- 

^ permalink raw reply

* Re: [PATCH] net/bonding: bonding: Adjust coding style for bond_3ad files.
From: Joe Perches @ 2011-05-04 23:49 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Rafael Azenha Aquini, kernel-janitors.vger.kernel.org,
	Jay Vosburgh, Andy Gospodarek, netdev
In-Reply-To: <20110504163803.57cde72e@nehalam>

On Wed, 2011-05-04 at 16:38 -0700, Stephen Hemminger wrote:
> On Wed, 4 May 2011 19:18:47 -0300
> Rafael Azenha Aquini <aquini@linux.com> wrote:
> > -// compare MAC addresses
> >  #define MAC_ADDRESS_COMPARE(A, B) memcmp(A, B, ETH_ALEN)
> >  static struct mac_addr null_mac_addr = { { 0, 0, 0, 0, 0, 0 } };
> These should be changed to use compare_ether_addr and is_zero_ether_addr
> routines in etherdevice.h

Hey Stephen.

null_mac_addr is used as a struct and should not be changed
to is_zero_ether_addr.
Maybe the uses could be changed to a memset, but I seem to
recall the code gets bigger.

drivers/net/bonding/bond_3ad.c:1637:		aggregator->partner_system = null_mac_addr;
drivers/net/bonding/bond_3ad.c:1660:		aggregator->aggregator_mac_address = null_mac_addr;
drivers/net/bonding/bond_3ad.c:1696:		port->actor_system = null_mac_addr;



^ permalink raw reply

* Re: tap/bridge: Dropping NETIF_F_GSO/NETIF_F_SG
From: Herbert Xu @ 2011-05-05  0:19 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: Michael S. Tsirkin, netdev, Ben Hutchings
In-Reply-To: <20110504232854.GA11687@rere.qmqm.pl>

On Thu, May 05, 2011 at 01:28:54AM +0200, Michał Mirosław wrote:
>
> Whatever application is creating the tap0 device is not calling
> ioctl(TUNSETOFFLOAD) with TUN_F_CSUM set. This is userspace bug/feature
> exposed by recent changes to netdev features handling.

OK, then user-space needs to be fixed.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply

* [PATCH] [RFC] vlan: fix updating wanted_features for vlan device
From: Yi Zou @ 2011-05-05  0:48 UTC (permalink / raw)
  To: netdev; +Cc: mirq-linux, jeffrey.t.kirsher, devel

commit 8a0427b "vlan: convert VLAN devices to use ndo_fix_features()" converts the
vlan to support ndo_fix_features. However, the wanted_features is not updated
for the vlan device, causing real_dev->features not be populated to the vlan
device when real_dev->features are changed by the driver through FEAT_CHANGE.
This is breaking FCoE related netdev feature flags on vlan devices. Add updating
wanted_features to vlan_transfer_features() so netdev_get_wanted_features() will
can get the updated wanted feature flags for vlan device properly.

I am sending as RFC in case the usage of wanted_features on vlan device is not
right, since the features chanaged are not directly from user doing ethtool, but
it is from user action of starting to run FCoE on a netdev instance. Anyway, let
let me know if there is a preferred alternative fix.

Signed-off-by: Yi Zou <yi.zou@intel.com>
---

 net/8021q/vlan.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 969e700..f2ee00b 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -332,6 +332,7 @@ static void vlan_transfer_features(struct net_device *dev,
 #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
 	vlandev->fcoe_ddp_xid = dev->fcoe_ddp_xid;
 #endif
+	vlandev->wanted_features |= dev->features & dev->vlan_features;
 
 	netdev_update_features(vlandev);
 }


^ permalink raw reply related

* [PATCHv2 1/2] net: Allow ethtool to set interface in loopback mode.
From: Mahesh Bandewar @ 2011-05-05  1:26 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, Ben Hutchings, Michał Mirosław, Tom Herbert,
	Mahesh Bandewar

This patch enables ethtool to set the loopback mode on a given interface.
By configuring the interface in loopback mode in conjunction with a policy
route / rule, a userland application can stress the egress / ingress path
exposing the flows of the change in progress and potentially help developer(s)
understand the impact of those changes without even sending a packet out
on the network.

Following set of commands illustrates one such example -
    a) ip -4 addr add 192.168.1.1/24 dev eth1
    b) ip -4 rule add from all iif eth1 lookup 250
    c) ip -4 route add local 0/0 dev lo proto kernel scope host table 250
    d) arp -Ds 192.168.1.100 eth1
    e) arp -Ds 192.168.1.200 eth1
    f) sysctl -w net.ipv4.ip_nonlocal_bind=1
    g) sysctl -w net.ipv4.conf.all.accept_local=1
    # Assuming that the machine has 8 cores
    h) taskset 000f netserver -L 192.168.1.200
    i) taskset 00f0 netperf -t TCP_CRR -L 192.168.1.100 -H 192.168.1.200 -l 30

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
---
Changes since v1
 Added NETIF_F_LOOPBACK in loopback device's feature-set.

 drivers/net/loopback.c    |    3 ++-
 include/linux/netdevice.h |    3 ++-
 net/core/ethtool.c        |    2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index d70fb76..4ce9e5f 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -174,7 +174,8 @@ static void loopback_setup(struct net_device *dev)
 		| NETIF_F_HIGHDMA
 		| NETIF_F_LLTX
 		| NETIF_F_NETNS_LOCAL
-		| NETIF_F_VLAN_CHALLENGED;
+		| NETIF_F_VLAN_CHALLENGED
+		| NETIF_F_LOOPBACK;
 	dev->ethtool_ops	= &loopback_ethtool_ops;
 	dev->header_ops		= &eth_header_ops;
 	dev->netdev_ops		= &loopback_ops;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d5de66a..e7244ed 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1067,6 +1067,7 @@ struct net_device {
 #define NETIF_F_RXHASH		(1 << 28) /* Receive hashing offload */
 #define NETIF_F_RXCSUM		(1 << 29) /* Receive checksumming offload */
 #define NETIF_F_NOCACHE_COPY	(1 << 30) /* Use no-cache copyfromuser */
+#define NETIF_F_LOOPBACK	(1 << 31) /* Enable loopback */
 
 	/* Segmentation offload features */
 #define NETIF_F_GSO_SHIFT	16
@@ -1082,7 +1083,7 @@ struct net_device {
 	/* = all defined minus driver/device-class-related */
 #define NETIF_F_NEVER_CHANGE	(NETIF_F_VLAN_CHALLENGED | \
 				  NETIF_F_LLTX | NETIF_F_NETNS_LOCAL)
-#define NETIF_F_ETHTOOL_BITS	(0x7f3fffff & ~NETIF_F_NEVER_CHANGE)
+#define NETIF_F_ETHTOOL_BITS	(0xff3fffff & ~NETIF_F_NEVER_CHANGE)
 
 	/* List of features with software fallbacks. */
 #define NETIF_F_GSO_SOFTWARE	(NETIF_F_TSO | NETIF_F_TSO_ECN | \
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index d8b1a8d..f26649d 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -362,7 +362,7 @@ static const char netdev_features_strings[ETHTOOL_DEV_FEATURE_WORDS * 32][ETH_GS
 	/* NETIF_F_RXHASH */          "rx-hashing",
 	/* NETIF_F_RXCSUM */          "rx-checksum",
 	/* NETIF_F_NOCACHE_COPY */    "tx-nocache-copy"
-	"",
+	/* NETIF_F_LOOPBACK */        "loopback",
 };
 
 static int __ethtool_get_sset_count(struct net_device *dev, int sset)
-- 
1.7.3.1


^ permalink raw reply related

* [PATCHv2 1/2] net: Allow ethtool to set interface in loopback mode.
From: Mahesh Bandewar @ 2011-05-05  1:30 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, Ben Hutchings, Michał Mirosław, Tom Herbert,
	Mahesh Bandewar
In-Reply-To: <1304471935-402-2-git-send-email-maheshb@google.com>

This patch enables ethtool to set the loopback mode on a given interface.
By configuring the interface in loopback mode in conjunction with a policy
route / rule, a userland application can stress the egress / ingress path
exposing the flows of the change in progress and potentially help developer(s)
understand the impact of those changes without even sending a packet out
on the network.

Following set of commands illustrates one such example -
    a) ip -4 addr add 192.168.1.1/24 dev eth1
    b) ip -4 rule add from all iif eth1 lookup 250
    c) ip -4 route add local 0/0 dev lo proto kernel scope host table 250
    d) arp -Ds 192.168.1.100 eth1
    e) arp -Ds 192.168.1.200 eth1
    f) sysctl -w net.ipv4.ip_nonlocal_bind=1
    g) sysctl -w net.ipv4.conf.all.accept_local=1
    # Assuming that the machine has 8 cores
    h) taskset 000f netserver -L 192.168.1.200
    i) taskset 00f0 netperf -t TCP_CRR -L 192.168.1.100 -H 192.168.1.200 -l 30

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
---
Changes since v1
 Added NETIF_F_LOOPBACK in loopback device's feature-set.

 drivers/net/loopback.c    |    3 ++-
 include/linux/netdevice.h |    3 ++-
 net/core/ethtool.c        |    2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index d70fb76..4ce9e5f 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -174,7 +174,8 @@ static void loopback_setup(struct net_device *dev)
 		| NETIF_F_HIGHDMA
 		| NETIF_F_LLTX
 		| NETIF_F_NETNS_LOCAL
-		| NETIF_F_VLAN_CHALLENGED;
+		| NETIF_F_VLAN_CHALLENGED
+		| NETIF_F_LOOPBACK;
 	dev->ethtool_ops	= &loopback_ethtool_ops;
 	dev->header_ops		= &eth_header_ops;
 	dev->netdev_ops		= &loopback_ops;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d5de66a..e7244ed 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1067,6 +1067,7 @@ struct net_device {
 #define NETIF_F_RXHASH		(1 << 28) /* Receive hashing offload */
 #define NETIF_F_RXCSUM		(1 << 29) /* Receive checksumming offload */
 #define NETIF_F_NOCACHE_COPY	(1 << 30) /* Use no-cache copyfromuser */
+#define NETIF_F_LOOPBACK	(1 << 31) /* Enable loopback */
 
 	/* Segmentation offload features */
 #define NETIF_F_GSO_SHIFT	16
@@ -1082,7 +1083,7 @@ struct net_device {
 	/* = all defined minus driver/device-class-related */
 #define NETIF_F_NEVER_CHANGE	(NETIF_F_VLAN_CHALLENGED | \
 				  NETIF_F_LLTX | NETIF_F_NETNS_LOCAL)
-#define NETIF_F_ETHTOOL_BITS	(0x7f3fffff & ~NETIF_F_NEVER_CHANGE)
+#define NETIF_F_ETHTOOL_BITS	(0xff3fffff & ~NETIF_F_NEVER_CHANGE)
 
 	/* List of features with software fallbacks. */
 #define NETIF_F_GSO_SOFTWARE	(NETIF_F_TSO | NETIF_F_TSO_ECN | \
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index d8b1a8d..f26649d 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -362,7 +362,7 @@ static const char netdev_features_strings[ETHTOOL_DEV_FEATURE_WORDS * 32][ETH_GS
 	/* NETIF_F_RXHASH */          "rx-hashing",
 	/* NETIF_F_RXCSUM */          "rx-checksum",
 	/* NETIF_F_NOCACHE_COPY */    "tx-nocache-copy"
-	"",
+	/* NETIF_F_LOOPBACK */        "loopback",
 };
 
 static int __ethtool_get_sset_count(struct net_device *dev, int sset)
-- 
1.7.3.1


^ permalink raw reply related

* [PATCHv4 2/2] tg3: Allow ethtool to enable/disable loopback.
From: Mahesh Bandewar @ 2011-05-05  1:34 UTC (permalink / raw)
  To: Matt Carlson, David Miller
  Cc: netdev, Michael Chan, Tom Herbert, Mahesh Bandewar
In-Reply-To: <1304471935-402-3-git-send-email-maheshb@google.com>

This patch adds tg3_set_features() to handle loopback mode. Currently the
capability is added for the devices which support internal MAC loopback mode.
So when enabled, it enables internal-MAC loopback.

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
---
Changes since v3:
 (a) Corrected the condition (|| => &&) where loopback capability is added.
 (b) set_features() always returns 0.
 (c) Clear the loopback bit in ndo_open callback to avoid discrepancy.

Changes since v2:
 Implemtned Joe Perches's style change.

Changes since v1:
 Implemented Matt Carlson's suggestions.
  (a) Enable this capability on the devices which are capable of MAC-loopback
      mode.
  (b) check if the device is running before making changes.
  (c) check bits before making changes.

 drivers/net/tg3.c |   69 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 7c7c9a8..7f7a290 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -6309,6 +6309,44 @@ dma_error:
 	return NETDEV_TX_OK;
 }
 
+static int tg3_set_loopback(struct net_device *dev, u32 features)
+{
+	struct tg3 *tp = netdev_priv(dev);
+	u32 cur_mode = 0;
+	int retval = 0;
+
+	spin_lock_bh(&tp->lock);
+	cur_mode = tr32(MAC_MODE);
+	if (features & NETIF_F_LOOPBACK) {
+		if (cur_mode & MAC_MODE_PORT_INT_LPBACK)
+			goto sfeatures_unlock;
+
+		/*
+		 * Clear MAC_MODE_HALF_DUPLEX or you won't get packets back in
+		 * loopback mode if Half-Duplex mode was negotiated earlier.
+		 */
+		cur_mode &= ~MAC_MODE_HALF_DUPLEX;
+
+		/* Enable internal MAC loopback mode */
+		tw32(MAC_MODE, cur_mode | MAC_MODE_PORT_INT_LPBACK);
+		netif_carrier_on(tp->dev);
+		netdev_info(dev, "Internal MAC loopback mode enabled.\n");
+	} else {
+		if (!(cur_mode & MAC_MODE_PORT_INT_LPBACK))
+			goto sfeatures_unlock;
+
+		/* Disable internal MAC loopback mode */
+		tw32(MAC_MODE, cur_mode & ~MAC_MODE_PORT_INT_LPBACK);
+		/* Force link status check */
+		tg3_setup_phy(tp, 1);
+		netdev_info(dev, "Internal MAC loopback mode disabled.\n");
+	}
+
+sfeatures_unlock:
+	spin_unlock_bh(&tp->lock);
+	return retval;
+}
+
 static u32 tg3_fix_features(struct net_device *dev, u32 features)
 {
 	struct tg3 *tp = netdev_priv(dev);
@@ -6319,6 +6357,16 @@ static u32 tg3_fix_features(struct net_device *dev, u32 features)
 	return features;
 }
 
+static int tg3_set_features(struct net_device *dev, u32 features)
+{
+	u32 changed = dev->features ^ features;
+
+	if ((changed & NETIF_F_LOOPBACK) && netif_running(dev))
+		tg3_set_loopback(dev, features);
+
+	return 0;
+}
+
 static inline void tg3_set_mtu(struct net_device *dev, struct tg3 *tp,
 			       int new_mtu)
 {
@@ -9485,6 +9533,15 @@ static int tg3_open(struct net_device *dev)
 
 	netif_tx_start_all_queues(dev);
 
+	/*
+	 * Reset loopback feature if it was turned on while the device was down
+	 * to avoid and any discrepancy in features reporting.
+	 */
+	if (dev->features & NETIF_F_LOOPBACK) {
+		dev->features &= ~NETIF_F_LOOPBACK;
+		dev->wanted_features &= ~NETIF_F_LOOPBACK;
+	}
+
 	return 0;
 
 err_out3:
@@ -15029,6 +15086,7 @@ static const struct net_device_ops tg3_netdev_ops = {
 	.ndo_tx_timeout		= tg3_tx_timeout,
 	.ndo_change_mtu		= tg3_change_mtu,
 	.ndo_fix_features	= tg3_fix_features,
+	.ndo_set_features	= tg3_set_features,
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	.ndo_poll_controller	= tg3_poll_controller,
 #endif
@@ -15045,6 +15103,7 @@ static const struct net_device_ops tg3_netdev_ops_dma_bug = {
 	.ndo_do_ioctl		= tg3_ioctl,
 	.ndo_tx_timeout		= tg3_tx_timeout,
 	.ndo_change_mtu		= tg3_change_mtu,
+	.ndo_set_features	= tg3_set_features,
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	.ndo_poll_controller	= tg3_poll_controller,
 #endif
@@ -15242,6 +15301,16 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
 	dev->features |= hw_features;
 	dev->vlan_features |= hw_features;
 
+	/*
+	 * Add loopback capability only for a subset of devices that support
+	 * MAC-LOOPBACK. Eventually this need to be enhanced to allow INT-PHY
+	 * loopback for the remaining devices.
+	 */
+	if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5780 &&
+	    !tg3_flag(tp, CPMU_PRESENT))
+		/* Add the loopback capability */
+		dev->hw_features |= NETIF_F_LOOPBACK;
+
 	if (tp->pci_chip_rev_id == CHIPREV_ID_5705_A1 &&
 	    !tg3_flag(tp, TSO_CAPABLE) &&
 	    !(tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH)) {
-- 
1.7.3.1


^ permalink raw reply related

* Re: [PATCHv2 1/2] net: Allow ethtool to set interface in loopback mode.
From: Ben Hutchings @ 2011-05-05  1:52 UTC (permalink / raw)
  To: Mahesh Bandewar
  Cc: David Miller, netdev, Michał Mirosław, Tom Herbert
In-Reply-To: <1304559011-15983-1-git-send-email-maheshb@google.com>

On Wed, 2011-05-04 at 18:30 -0700, Mahesh Bandewar wrote:
> This patch enables ethtool to set the loopback mode on a given interface.
> By configuring the interface in loopback mode in conjunction with a policy
> route / rule, a userland application can stress the egress / ingress path
> exposing the flows of the change in progress and potentially help developer(s)
> understand the impact of those changes without even sending a packet out
> on the network.
> 
> Following set of commands illustrates one such example -
>     a) ip -4 addr add 192.168.1.1/24 dev eth1
>     b) ip -4 rule add from all iif eth1 lookup 250
>     c) ip -4 route add local 0/0 dev lo proto kernel scope host table 250
>     d) arp -Ds 192.168.1.100 eth1
>     e) arp -Ds 192.168.1.200 eth1
>     f) sysctl -w net.ipv4.ip_nonlocal_bind=1
>     g) sysctl -w net.ipv4.conf.all.accept_local=1
>     # Assuming that the machine has 8 cores
>     h) taskset 000f netserver -L 192.168.1.200
>     i) taskset 00f0 netperf -t TCP_CRR -L 192.168.1.100 -H 192.168.1.200 -l 30
> 
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
Acked-by: Ben Hutchings <bhutchings@solarflare.com>

-- 
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


^ permalink raw reply

* Re: [PATCHv2 1/2] net: Allow ethtool to set interface in loopback mode.
From: Mahesh Bandewar @ 2011-05-05  1:28 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, Ben Hutchings, Michał Mirosław, Tom Herbert,
	Mahesh Bandewar
In-Reply-To: <1304558800-15877-1-git-send-email-maheshb@google.com>

Please discard this, I do not wish to create a new thread for this.

Thanks,
--mahesh..

On Wed, May 4, 2011 at 6:26 PM, Mahesh Bandewar <maheshb@google.com> wrote:
> This patch enables ethtool to set the loopback mode on a given interface.
> By configuring the interface in loopback mode in conjunction with a policy
> route / rule, a userland application can stress the egress / ingress path
> exposing the flows of the change in progress and potentially help developer(s)
> understand the impact of those changes without even sending a packet out
> on the network.
>
> Following set of commands illustrates one such example -
>    a) ip -4 addr add 192.168.1.1/24 dev eth1
>    b) ip -4 rule add from all iif eth1 lookup 250
>    c) ip -4 route add local 0/0 dev lo proto kernel scope host table 250
>    d) arp -Ds 192.168.1.100 eth1
>    e) arp -Ds 192.168.1.200 eth1
>    f) sysctl -w net.ipv4.ip_nonlocal_bind=1
>    g) sysctl -w net.ipv4.conf.all.accept_local=1
>    # Assuming that the machine has 8 cores
>    h) taskset 000f netserver -L 192.168.1.200
>    i) taskset 00f0 netperf -t TCP_CRR -L 192.168.1.100 -H 192.168.1.200 -l 30
>
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
> ---
> Changes since v1
>  Added NETIF_F_LOOPBACK in loopback device's feature-set.
>
>  drivers/net/loopback.c    |    3 ++-
>  include/linux/netdevice.h |    3 ++-
>  net/core/ethtool.c        |    2 +-
>  3 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
> index d70fb76..4ce9e5f 100644
> --- a/drivers/net/loopback.c
> +++ b/drivers/net/loopback.c
> @@ -174,7 +174,8 @@ static void loopback_setup(struct net_device *dev)
>                | NETIF_F_HIGHDMA
>                | NETIF_F_LLTX
>                | NETIF_F_NETNS_LOCAL
> -               | NETIF_F_VLAN_CHALLENGED;
> +               | NETIF_F_VLAN_CHALLENGED
> +               | NETIF_F_LOOPBACK;
>        dev->ethtool_ops        = &loopback_ethtool_ops;
>        dev->header_ops         = &eth_header_ops;
>        dev->netdev_ops         = &loopback_ops;
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index d5de66a..e7244ed 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -1067,6 +1067,7 @@ struct net_device {
>  #define NETIF_F_RXHASH         (1 << 28) /* Receive hashing offload */
>  #define NETIF_F_RXCSUM         (1 << 29) /* Receive checksumming offload */
>  #define NETIF_F_NOCACHE_COPY   (1 << 30) /* Use no-cache copyfromuser */
> +#define NETIF_F_LOOPBACK       (1 << 31) /* Enable loopback */
>
>        /* Segmentation offload features */
>  #define NETIF_F_GSO_SHIFT      16
> @@ -1082,7 +1083,7 @@ struct net_device {
>        /* = all defined minus driver/device-class-related */
>  #define NETIF_F_NEVER_CHANGE   (NETIF_F_VLAN_CHALLENGED | \
>                                  NETIF_F_LLTX | NETIF_F_NETNS_LOCAL)
> -#define NETIF_F_ETHTOOL_BITS   (0x7f3fffff & ~NETIF_F_NEVER_CHANGE)
> +#define NETIF_F_ETHTOOL_BITS   (0xff3fffff & ~NETIF_F_NEVER_CHANGE)
>
>        /* List of features with software fallbacks. */
>  #define NETIF_F_GSO_SOFTWARE   (NETIF_F_TSO | NETIF_F_TSO_ECN | \
> diff --git a/net/core/ethtool.c b/net/core/ethtool.c
> index d8b1a8d..f26649d 100644
> --- a/net/core/ethtool.c
> +++ b/net/core/ethtool.c
> @@ -362,7 +362,7 @@ static const char netdev_features_strings[ETHTOOL_DEV_FEATURE_WORDS * 32][ETH_GS
>        /* NETIF_F_RXHASH */          "rx-hashing",
>        /* NETIF_F_RXCSUM */          "rx-checksum",
>        /* NETIF_F_NOCACHE_COPY */    "tx-nocache-copy"
> -       "",
> +       /* NETIF_F_LOOPBACK */        "loopback",
>  };
>
>  static int __ethtool_get_sset_count(struct net_device *dev, int sset)
> --
> 1.7.3.1
>
>

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox