netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: netdev@vger.kernel.org, gospo@redhat.com,
	Greg Rose <gregory.v.rose@intel.com>
Subject: Re: [RFC PATCH v2 02/12] ixgbevf: 82599 Virtual Function core functions and header
Date: Mon, 21 Dec 2009 16:03:42 +1100	[thread overview]
Message-ID: <20091221050341.GA22037@verge.net.au> (raw)
In-Reply-To: <20091218225123.10698.8625.stgit@localhost.localdomain>

On Fri, Dec 18, 2009 at 02:51:23PM -0800, Jeff Kirsher wrote:
> From: Greg Rose <gregory.v.rose@intel.com>
> 
> This module and header file contain the core functions for the 82599
> virtual function device.
> 
> Signed-off-by: Greg Rose <gregory.v.rose@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> ---
> 
>  drivers/net/ixgbevf/vf.c |  410 ++++++++++++++++++++++++++++++++++++++++++++++
>  drivers/net/ixgbevf/vf.h |  168 +++++++++++++++++++
>  2 files changed, 578 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/net/ixgbevf/vf.c
>  create mode 100644 drivers/net/ixgbevf/vf.h
> 
> diff --git a/drivers/net/ixgbevf/vf.c b/drivers/net/ixgbevf/vf.c
> new file mode 100644
> index 0000000..38784eb
> --- /dev/null
> +++ b/drivers/net/ixgbevf/vf.c
> @@ -0,0 +1,410 @@

[snip]

> +
> +#include "vf.h"
> +
> +static s32 ixgbevf_init_hw_vf(struct ixgbe_hw *hw);
> +static s32 ixgbevf_start_hw_vf(struct ixgbe_hw *hw);
> +static s32 ixgbevf_reset_hw_vf(struct ixgbe_hw *hw);
> +static s32 ixgbevf_stop_hw_vf(struct ixgbe_hw *hw);
> +static s32 ixgbevf_get_mac_addr_vf(struct ixgbe_hw *hw, u8 *mac_addr);
> +static s32 ixgbevf_setup_mac_link_vf(struct ixgbe_hw *hw,
> +				   ixgbe_link_speed speed, bool autoneg,
> +				   bool autoneg_wait_to_complete);
> +static s32 ixgbevf_check_mac_link_vf(struct ixgbe_hw *hw,
> +				   ixgbe_link_speed *speed,
> +				   bool *link_up,
> +				   bool autoneg_wait_to_complete);
> +static s32 ixgbevf_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 *addr,
> +			      u32 vmdq);
> +static s32 ixgbevf_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 *mc_addr_list,
> +					u32 mc_addr_count, ixgbe_mc_addr_itr);
> +static s32 ixgbevf_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
> +			     bool vlan_on);

It seems that if the definition of ixgbevf_get_mac_addr_vf() was moved to
before ixgbevf_set_rar_vf() then all of the above static declarations could
be removed.

[snip]

> +/**
> + *  ixgbevf_reset_hw_vf - Performs hardware reset
> + *  @hw: pointer to hardware structure
> + *
> + *  Resets the hardware by reseting the transmit and receive units, masks and
> + *  clears all interrupts.
> + **/
> +static s32 ixgbevf_reset_hw_vf(struct ixgbe_hw *hw)
> +{
> +	struct ixgbe_mbx_info *mbx = &hw->mbx;
> +	u32 timeout = IXGBE_VF_INIT_TIMEOUT;
> +	s32 ret_val = IXGBE_ERR_INVALID_MAC_ADDR;
> +	u32 msgbuf[IXGBE_VF_PERMADDR_MSG_LEN];
> +	u8 *addr = (u8 *)(&msgbuf[1]);
> +
> +	/* Call adapter stop to disable tx/rx and clear interrupts */
> +	hw->mac.ops.stop_adapter(hw);
> +
> +	IXGBE_WRITE_REG(hw, IXGBE_VFCTRL, IXGBE_CTRL_RST);
> +	IXGBE_WRITE_FLUSH(hw);
> +
> +	/* we cannot reset while the RSTI / RSTD bits are asserted */
> +	while (!mbx->ops.check_for_rst(hw) && timeout) {
> +		timeout--;
> +		udelay(5);
> +	}
> +
> +	if (timeout) {
> +		/* mailbox timeout can now become active */
> +		mbx->timeout = IXGBE_VF_MBX_INIT_TIMEOUT;
> +
> +		msgbuf[0] = IXGBE_VF_RESET;
> +		mbx->ops.write_posted(hw, msgbuf, 1);
> +
> +		msleep(10);
> +
> +		/* set our "perm_addr" based on info provided by PF */
> +		/* also set up the mc_filter_type which is piggy backed
> +		 * on the mac address in word 3 */
> +		ret_val = mbx->ops.read_posted(hw, msgbuf,
> +					       IXGBE_VF_PERMADDR_MSG_LEN);
> +		if (!ret_val) {
> +			if (msgbuf[0] == (IXGBE_VF_RESET |
> +					  IXGBE_VT_MSGTYPE_ACK)) {
> +				memcpy(hw->mac.perm_addr, addr,
> +				       IXGBE_ETH_LENGTH_OF_ADDRESS);
> +				hw->mac.mc_filter_type =
> +					msgbuf[IXGBE_VF_MC_TYPE_WORD];
> +			} else {
> +				ret_val = IXGBE_ERR_INVALID_MAC_ADDR;
> +			}
> +		}
> +	}
> +
> +	return ret_val;
> +}

I wonder if it would be easier to follow the flow of ixgbevf_reset_hw_vf()
if it was written as:

static s32 ixgbevf_reset_hw_vf(struct ixgbe_hw *hw)
{
	struct ixgbe_mbx_info *mbx = &hw->mbx;
	u32 timeout = IXGBE_VF_INIT_TIMEOUT;
	s32 ret_val;
	u32 msgbuf[IXGBE_VF_PERMADDR_MSG_LEN];
	u8 *addr = (u8 *)(&msgbuf[1]);

	/* Call adapter stop to disable tx/rx and clear interrupts */
	hw->mac.ops.stop_adapter(hw);

	IXGBE_WRITE_REG(hw, IXGBE_VFCTRL, IXGBE_CTRL_RST);
	IXGBE_WRITE_FLUSH(hw);

	/* we cannot reset while the RSTI / RSTD bits are asserted */
	while (!mbx->ops.check_for_rst(hw) && timeout) {
		timeout--;
		udelay(5);
	}

	if (!timeout)
		return IXGBE_ERR_INVALID_MAC_ADDR;

	/* mailbox timeout can now become active */
	mbx->timeout = IXGBE_VF_MBX_INIT_TIMEOUT;

	msgbuf[0] = IXGBE_VF_RESET;
	mbx->ops.write_posted(hw, msgbuf, 1);

	msleep(10);

	/* Set our "perm_addr" based on info provided by PF.
	 * Also set up the mc_filter_type which is piggy backed
	 * on the mac address in word 3
	 */
	ret_val = mbx->ops.read_posted(hw, msgbuf, IXGBE_VF_PERMADDR_MSG_LEN);
	if (ret_val)
		return ret_val;

	if (msgbuf[0] != (IXGBE_VF_RESET | IXGBE_VT_MSGTYPE_ACK))
		return IXGBE_ERR_INVALID_MAC_ADDR;

	memcpy(hw->mac.perm_addr, addr, IXGBE_ETH_LENGTH_OF_ADDRESS);
	hw->mac.mc_filter_type = msgbuf[IXGBE_VF_MC_TYPE_WORD];

	return 0;
}


  reply	other threads:[~2009-12-21  5:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-18 22:51 [RFC PATCH v2 01/12] ixgbevf: Macros, data structures, useful defines and registers Jeff Kirsher
2009-12-18 22:51 ` [RFC PATCH v2 02/12] ixgbevf: 82599 Virtual Function core functions and header Jeff Kirsher
2009-12-21  5:03   ` Simon Horman [this message]
2009-12-23 20:22   ` Ben Hutchings
2009-12-23 21:36     ` Rose, Gregory V
2009-12-18 22:51 ` [RFC PATCH v2 03/12] ixgbevf: Mailbox communication Jeff Kirsher
2009-12-23 20:28   ` Ben Hutchings
2009-12-23 21:38     ` Rose, Gregory V
2009-12-18 22:51 ` [RFC PATCH v2 04/12] ixgbevf: Driver main and ethool interface module and main header Jeff Kirsher
2009-12-21  7:59   ` Simon Horman
2009-12-21 18:18     ` Rose, Gregory V
2009-12-23  0:05     ` Rose, Gregory V
2009-12-18 22:52 ` [RFC PATCH v2 05/12] ixgbevf: Driver Makefile Jeff Kirsher
2009-12-18 22:52 ` [RFC PATCH v2 06/12] ixgbevf: Kconfig, Makefile and Documentation Jeff Kirsher
2009-12-18 22:52 ` [RFC PATCH v2 07/12] ixgbe: Mailbox header and code module Jeff Kirsher
2009-12-18 22:53 ` [RFC PATCH v2 08/12] ixgbe: Add SR-IOV register, structure and bit defines Jeff Kirsher
2009-12-18 22:53 ` [RFC PATCH v2 09/12] ixgbe: Add SR-IOV specific features Jeff Kirsher
2009-12-18 22:53 ` [RFC PATCH v2 10/12] ixgbe: Add SR-IOV specific modules to driver Makefile Jeff Kirsher
2009-12-18 22:53 ` [RFC PATCH v2 11/12] ixgbe: Add SR-IOV feature enablement code Jeff Kirsher
2009-12-18 22:54 ` [RFC PATCH v2 12/12] ixgbe: Add SR-IOV features to main module Jeff Kirsher
2009-12-21 18:38 ` [RFC PATCH v2 01/12] ixgbevf: Macros, data structures, useful defines and registers Ben Hutchings
2009-12-21 18:51   ` Rose, Gregory V

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091221050341.GA22037@verge.net.au \
    --to=horms@verge.net.au \
    --cc=gospo@redhat.com \
    --cc=gregory.v.rose@intel.com \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).