Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234061
b: refs/heads/master
c: bef6e7e
h: refs/heads/master
i:
  234059: 805b089
v: v3
  • Loading branch information
David S. Miller committed Mar 10, 2011
1 parent 3757e92 commit 0522aa1
Show file tree
Hide file tree
Showing 20 changed files with 182 additions and 106 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9179746652faf0aba07b8b7f770dcf29892a24c6
refs/heads/master: bef6e7e76868ab454d5e83635a4a7a1961c74fb5
5 changes: 1 addition & 4 deletions trunk/MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -4292,10 +4292,7 @@ S: Maintained
F: net/sched/sch_netem.c

NETERION 10GbE DRIVERS (s2io/vxge)
M: Ramkrishna Vepa <ramkrishna.vepa@exar.com>
M: Sivakumar Subramani <sivakumar.subramani@exar.com>
M: Sreenivasa Honnur <sreenivasa.honnur@exar.com>
M: Jon Mason <jon.mason@exar.com>
M: Jon Mason <jdmason@kudzu.us>
L: netdev@vger.kernel.org
W: http://trac.neterion.com/cgi-bin/trac.cgi/wiki/Linux?Anonymous
W: http://trac.neterion.com/cgi-bin/trac.cgi/wiki/X3100Linux?Anonymous
Expand Down
5 changes: 3 additions & 2 deletions trunk/drivers/net/bnx2x/bnx2x.h
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,7 @@ struct bnx2x {
/* DCBX Negotation results */
struct dcbx_features dcbx_local_feat;
u32 dcbx_error;
u32 pending_max;
};

/**
Expand Down Expand Up @@ -1616,8 +1617,8 @@ static inline u32 reg_poll(struct bnx2x *bp, u32 reg, u32 expected, int ms,
/* CMNG constants, as derived from system spec calculations */
/* default MIN rate in case VNIC min rate is configured to zero - 100Mbps */
#define DEF_MIN_RATE 100
/* resolution of the rate shaping timer - 100 usec */
#define RS_PERIODIC_TIMEOUT_USEC 100
/* resolution of the rate shaping timer - 400 usec */
#define RS_PERIODIC_TIMEOUT_USEC 400
/* number of bytes in single QM arbitration cycle -
* coefficient for calculating the fairness timer */
#define QM_ARB_BYTES 160000
Expand Down
22 changes: 22 additions & 0 deletions trunk/drivers/net/bnx2x/bnx2x_cmn.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,23 @@ void bnx2x_free_skbs(struct bnx2x *bp)
bnx2x_free_rx_skbs(bp);
}

void bnx2x_update_max_mf_config(struct bnx2x *bp, u32 value)
{
/* load old values */
u32 mf_cfg = bp->mf_config[BP_VN(bp)];

if (value != bnx2x_extract_max_cfg(bp, mf_cfg)) {
/* leave all but MAX value */
mf_cfg &= ~FUNC_MF_CFG_MAX_BW_MASK;

/* set new MAX value */
mf_cfg |= (value << FUNC_MF_CFG_MAX_BW_SHIFT)
& FUNC_MF_CFG_MAX_BW_MASK;

bnx2x_fw_command(bp, DRV_MSG_CODE_SET_MF_BW, mf_cfg);
}
}

static void bnx2x_free_msix_irqs(struct bnx2x *bp)
{
int i, offset = 1;
Expand Down Expand Up @@ -1464,6 +1481,11 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)

bnx2x_set_eth_mac(bp, 1);

if (bp->pending_max) {
bnx2x_update_max_mf_config(bp, bp->pending_max);
bp->pending_max = 0;
}

if (bp->port.pmf)
bnx2x_initial_phy_init(bp, load_mode);

Expand Down
9 changes: 9 additions & 0 deletions trunk/drivers/net/bnx2x/bnx2x_cmn.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,15 @@ void bnx2x_dcbx_init(struct bnx2x *bp);
*/
int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state);

/**
* Updates MAX part of MF configuration in HW
* (if required)
*
* @param bp
* @param value
*/
void bnx2x_update_max_mf_config(struct bnx2x *bp, u32 value);

/* dev_close main block */
int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode);

Expand Down
18 changes: 8 additions & 10 deletions trunk/drivers/net/bnx2x/bnx2x_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
speed |= (cmd->speed_hi << 16);

if (IS_MF_SI(bp)) {
u32 param = 0, part;
u32 part;
u32 line_speed = bp->link_vars.line_speed;

/* use 10G if no link detected */
Expand All @@ -251,24 +251,22 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
REQ_BC_VER_4_SET_MF_BW);
return -EINVAL;
}

part = (speed * 100) / line_speed;

if (line_speed < speed || !part) {
BNX2X_DEV_INFO("Speed setting should be in a range "
"from 1%% to 100%% "
"of actual line speed\n");
return -EINVAL;
}
/* load old values */
param = bp->mf_config[BP_VN(bp)];

/* leave only MIN value */
param &= FUNC_MF_CFG_MIN_BW_MASK;

/* set new MAX value */
param |= (part << FUNC_MF_CFG_MAX_BW_SHIFT)
& FUNC_MF_CFG_MAX_BW_MASK;
if (bp->state != BNX2X_STATE_OPEN)
/* store value for following "load" */
bp->pending_max = part;
else
bnx2x_update_max_mf_config(bp, part);

bnx2x_fw_command(bp, DRV_MSG_CODE_SET_MF_BW, param);
return 0;
}

Expand Down
19 changes: 10 additions & 9 deletions trunk/drivers/net/bnx2x/bnx2x_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2092,8 +2092,9 @@ static void bnx2x_cmng_fns_init(struct bnx2x *bp, u8 read_cfg, u8 cmng_type)
bnx2x_calc_vn_weight_sum(bp);

/* calculate and set min-max rate for each vn */
for (vn = VN_0; vn < E1HVN_MAX; vn++)
bnx2x_init_vn_minmax(bp, vn);
if (bp->port.pmf)
for (vn = VN_0; vn < E1HVN_MAX; vn++)
bnx2x_init_vn_minmax(bp, vn);

/* always enable rate shaping and fairness */
bp->cmng.flags.cmng_enables |=
Expand Down Expand Up @@ -2162,13 +2163,6 @@ static void bnx2x_link_attn(struct bnx2x *bp)
bnx2x_stats_handle(bp, STATS_EVENT_LINK_UP);
}

/* indicate link status only if link status actually changed */
if (prev_link_status != bp->link_vars.link_status)
bnx2x_link_report(bp);

if (IS_MF(bp))
bnx2x_link_sync_notify(bp);

if (bp->link_vars.link_up && bp->link_vars.line_speed) {
int cmng_fns = bnx2x_get_cmng_fns_mode(bp);

Expand All @@ -2180,6 +2174,13 @@ static void bnx2x_link_attn(struct bnx2x *bp)
DP(NETIF_MSG_IFUP,
"single function mode without fairness\n");
}

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)
Expand Down
32 changes: 19 additions & 13 deletions trunk/drivers/net/bonding/bond_3ad.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,23 +281,23 @@ static inline int __check_agg_selection_timer(struct port *port)
}

/**
* __get_rx_machine_lock - lock the port's RX machine
* __get_state_machine_lock - lock the port's state machines
* @port: the port we're looking at
*
*/
static inline void __get_rx_machine_lock(struct port *port)
static inline void __get_state_machine_lock(struct port *port)
{
spin_lock_bh(&(SLAVE_AD_INFO(port->slave).rx_machine_lock));
spin_lock_bh(&(SLAVE_AD_INFO(port->slave).state_machine_lock));
}

/**
* __release_rx_machine_lock - unlock the port's RX machine
* __release_state_machine_lock - unlock the port's state machines
* @port: the port we're looking at
*
*/
static inline void __release_rx_machine_lock(struct port *port)
static inline void __release_state_machine_lock(struct port *port)
{
spin_unlock_bh(&(SLAVE_AD_INFO(port->slave).rx_machine_lock));
spin_unlock_bh(&(SLAVE_AD_INFO(port->slave).state_machine_lock));
}

/**
Expand Down Expand Up @@ -388,14 +388,14 @@ static u8 __get_duplex(struct port *port)
}

/**
* __initialize_port_locks - initialize a port's RX machine spinlock
* __initialize_port_locks - initialize a port's STATE machine spinlock
* @port: the port we're looking at
*
*/
static inline void __initialize_port_locks(struct port *port)
{
// make sure it isn't called twice
spin_lock_init(&(SLAVE_AD_INFO(port->slave).rx_machine_lock));
spin_lock_init(&(SLAVE_AD_INFO(port->slave).state_machine_lock));
}

//conversions
Expand Down Expand Up @@ -1025,9 +1025,6 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
{
rx_states_t last_state;

// Lock to prevent 2 instances of this function to run simultaneously(rx interrupt and periodic machine callback)
__get_rx_machine_lock(port);

// keep current State Machine state to compare later if it was changed
last_state = port->sm_rx_state;

Expand Down Expand Up @@ -1133,7 +1130,6 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
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);
__release_rx_machine_lock(port);
return;
}
__update_selected(lacpdu, port);
Expand All @@ -1153,7 +1149,6 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
break;
}
}
__release_rx_machine_lock(port);
}

/**
Expand Down Expand Up @@ -2155,6 +2150,12 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
goto re_arm;
}

/* Lock around state machines to protect data accessed
* by all (e.g., port->sm_vars). ad_rx_machine may run
* concurrently due to incoming LACPDU.
*/
__get_state_machine_lock(port);

ad_rx_machine(NULL, port);
ad_periodic_machine(port);
ad_port_selection_logic(port);
Expand All @@ -2164,6 +2165,8 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
// turn off the BEGIN bit, since we already handled it
if (port->sm_vars & AD_PORT_BEGIN)
port->sm_vars &= ~AD_PORT_BEGIN;

__release_state_machine_lock(port);
}

re_arm:
Expand Down Expand Up @@ -2200,7 +2203,10 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
case AD_TYPE_LACPDU:
pr_debug("Received LACPDU on port %d\n",
port->actor_port_number);
/* Protect against concurrent state machines */
__get_state_machine_lock(port);
ad_rx_machine(lacpdu, port);
__release_state_machine_lock(port);
break;

case AD_TYPE_MARKER:
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/net/bonding/bond_3ad.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ struct ad_bond_info {
struct ad_slave_info {
struct aggregator aggregator; // 802.3ad aggregator structure
struct port port; // 802.3ad port structure
spinlock_t rx_machine_lock; // To avoid race condition between callback and receive interrupt
spinlock_t state_machine_lock; /* mutex state machines vs.
incoming LACPDU */
u16 id;
};

Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/net/macvtap.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,9 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q,
vnet_hdr_len = q->vnet_hdr_sz;

err = -EINVAL;
if ((len -= vnet_hdr_len) < 0)
if (len < vnet_hdr_len)
goto err;
len -= vnet_hdr_len;

err = memcpy_fromiovecend((void *)&vnet_hdr, iv, 0,
sizeof(vnet_hdr));
Expand Down
Loading

0 comments on commit 0522aa1

Please sign in to comment.