i40e: Tx/Rx rings declaration

This patch changes the declaration of Tx/Rx rings inside several loops. It
eliminates declaring the same rings every time for the duration of the loop,
instead declaring them once before the loop.

Change-ID: I59dea54276f18c47dca522f520c18f65fe42a15d
Signed-off-by: Akeem G Abodunrin <akeem.g.abodunrin@intel.com>
Tested-by: Kavindya Deegala <kavindya.s.deegala@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
This commit is contained in:
Akeem G Abodunrin 2014-04-09 05:58:58 +00:00 committed by Jeff Kirsher
parent 84590fd90e
commit e7046ee1f8
2 changed files with 7 additions and 8 deletions

View File

@ -633,6 +633,7 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats *stats, u64 *data) struct ethtool_stats *stats, u64 *data)
{ {
struct i40e_netdev_priv *np = netdev_priv(netdev); struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_ring *tx_ring, *rx_ring;
struct i40e_vsi *vsi = np->vsi; struct i40e_vsi *vsi = np->vsi;
struct i40e_pf *pf = vsi->back; struct i40e_pf *pf = vsi->back;
int i = 0; int i = 0;
@ -650,8 +651,7 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
} }
rcu_read_lock(); rcu_read_lock();
for (j = 0; j < vsi->num_queue_pairs; j++) { for (j = 0; j < vsi->num_queue_pairs; j++) {
struct i40e_ring *tx_ring = ACCESS_ONCE(vsi->tx_rings[j]); tx_ring = ACCESS_ONCE(vsi->tx_rings[j]);
struct i40e_ring *rx_ring;
if (!tx_ring) if (!tx_ring)
continue; continue;

View File

@ -356,6 +356,7 @@ static struct rtnl_link_stats64 *i40e_get_netdev_stats_struct(
struct rtnl_link_stats64 *stats) struct rtnl_link_stats64 *stats)
{ {
struct i40e_netdev_priv *np = netdev_priv(netdev); struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_ring *tx_ring, *rx_ring;
struct i40e_vsi *vsi = np->vsi; struct i40e_vsi *vsi = np->vsi;
struct rtnl_link_stats64 *vsi_stats = i40e_get_vsi_stats_struct(vsi); struct rtnl_link_stats64 *vsi_stats = i40e_get_vsi_stats_struct(vsi);
int i; int i;
@ -368,7 +369,6 @@ static struct rtnl_link_stats64 *i40e_get_netdev_stats_struct(
rcu_read_lock(); rcu_read_lock();
for (i = 0; i < vsi->num_queue_pairs; i++) { for (i = 0; i < vsi->num_queue_pairs; i++) {
struct i40e_ring *tx_ring, *rx_ring;
u64 bytes, packets; u64 bytes, packets;
unsigned int start; unsigned int start;
@ -2415,6 +2415,7 @@ static int i40e_vsi_configure_rx(struct i40e_vsi *vsi)
**/ **/
static void i40e_vsi_config_dcb_rings(struct i40e_vsi *vsi) static void i40e_vsi_config_dcb_rings(struct i40e_vsi *vsi)
{ {
struct i40e_ring *tx_ring, *rx_ring;
u16 qoffset, qcount; u16 qoffset, qcount;
int i, n; int i, n;
@ -2428,8 +2429,8 @@ static void i40e_vsi_config_dcb_rings(struct i40e_vsi *vsi)
qoffset = vsi->tc_config.tc_info[n].qoffset; qoffset = vsi->tc_config.tc_info[n].qoffset;
qcount = vsi->tc_config.tc_info[n].qcount; qcount = vsi->tc_config.tc_info[n].qcount;
for (i = qoffset; i < (qoffset + qcount); i++) { for (i = qoffset; i < (qoffset + qcount); i++) {
struct i40e_ring *rx_ring = vsi->rx_rings[i]; rx_ring = vsi->rx_rings[i];
struct i40e_ring *tx_ring = vsi->tx_rings[i]; tx_ring = vsi->tx_rings[i];
rx_ring->dcb_tc = n; rx_ring->dcb_tc = n;
tx_ring->dcb_tc = n; tx_ring->dcb_tc = n;
} }
@ -5948,14 +5949,12 @@ static void i40e_vsi_clear_rings(struct i40e_vsi *vsi)
**/ **/
static int i40e_alloc_rings(struct i40e_vsi *vsi) static int i40e_alloc_rings(struct i40e_vsi *vsi)
{ {
struct i40e_ring *tx_ring, *rx_ring;
struct i40e_pf *pf = vsi->back; struct i40e_pf *pf = vsi->back;
int i; int i;
/* Set basic values in the rings to be used later during open() */ /* Set basic values in the rings to be used later during open() */
for (i = 0; i < vsi->alloc_queue_pairs; i++) { for (i = 0; i < vsi->alloc_queue_pairs; i++) {
struct i40e_ring *tx_ring;
struct i40e_ring *rx_ring;
/* allocate space for both Tx and Rx in one shot */ /* allocate space for both Tx and Rx in one shot */
tx_ring = kzalloc(sizeof(struct i40e_ring) * 2, GFP_KERNEL); tx_ring = kzalloc(sizeof(struct i40e_ring) * 2, GFP_KERNEL);
if (!tx_ring) if (!tx_ring)