Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 247042
b: refs/heads/master
c: 14ad251
h: refs/heads/master
v: v3
  • Loading branch information
David Decotigny authored and David S. Miller committed Apr 29, 2011
1 parent a3b23a5 commit ce5cd91
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 39 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: fbef7139a8b89a7f49ba1410593ed894b4c8b017
refs/heads/master: 14ad2513ed5b709e566a853f4b515d91c5d83311
2 changes: 1 addition & 1 deletion trunk/drivers/net/e1000/e1000.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ extern int e1000_up(struct e1000_adapter *adapter);
extern void e1000_down(struct e1000_adapter *adapter);
extern void e1000_reinit_locked(struct e1000_adapter *adapter);
extern void e1000_reset(struct e1000_adapter *adapter);
extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx);
extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx);
extern int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
extern int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
extern void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/e1000/e1000_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static int e1000_set_settings(struct net_device *netdev,
ecmd->advertising = hw->autoneg_advertised;
} else {
u32 speed = ethtool_cmd_speed(ecmd);
if (e1000_set_spd_dplx(adapter, speed + ecmd->duplex)) {
if (e1000_set_spd_dplx(adapter, speed, ecmd->duplex)) {
clear_bit(__E1000_RESETTING, &adapter->flags);
return -EINVAL;
}
Expand Down
42 changes: 24 additions & 18 deletions trunk/drivers/net/e1000/e1000_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ int e1000_up(struct e1000_adapter *adapter);
void e1000_down(struct e1000_adapter *adapter);
void e1000_reinit_locked(struct e1000_adapter *adapter);
void e1000_reset(struct e1000_adapter *adapter);
int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx);
int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
Expand Down Expand Up @@ -4385,7 +4384,6 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
struct mii_ioctl_data *data = if_mii(ifr);
int retval;
u16 mii_reg;
u16 spddplx;
unsigned long flags;

if (hw->media_type != e1000_media_type_copper)
Expand Down Expand Up @@ -4424,17 +4422,18 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
hw->autoneg = 1;
hw->autoneg_advertised = 0x2F;
} else {
u32 speed;
if (mii_reg & 0x40)
spddplx = SPEED_1000;
speed = SPEED_1000;
else if (mii_reg & 0x2000)
spddplx = SPEED_100;
speed = SPEED_100;
else
spddplx = SPEED_10;
spddplx += (mii_reg & 0x100)
? DUPLEX_FULL :
DUPLEX_HALF;
retval = e1000_set_spd_dplx(adapter,
spddplx);
speed = SPEED_10;
retval = e1000_set_spd_dplx(
adapter, speed,
((mii_reg & 0x100)
? DUPLEX_FULL :
DUPLEX_HALF));
if (retval)
return retval;
}
Expand Down Expand Up @@ -4596,20 +4595,24 @@ static void e1000_restore_vlan(struct e1000_adapter *adapter)
}
}

int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx)
{
struct e1000_hw *hw = &adapter->hw;

hw->autoneg = 0;

/* Make sure dplx is at most 1 bit and lsb of speed is not set
* for the switch() below to work */
if ((spd & 1) || (dplx & ~1))
goto err_inval;

/* Fiber NICs only allow 1000 gbps Full duplex */
if ((hw->media_type == e1000_media_type_fiber) &&
spddplx != (SPEED_1000 + DUPLEX_FULL)) {
e_err(probe, "Unsupported Speed/Duplex configuration\n");
return -EINVAL;
}
spd != SPEED_1000 &&
dplx != DUPLEX_FULL)
goto err_inval;

switch (spddplx) {
switch (spd + dplx) {
case SPEED_10 + DUPLEX_HALF:
hw->forced_speed_duplex = e1000_10_half;
break;
Expand All @@ -4628,10 +4631,13 @@ int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
break;
case SPEED_1000 + DUPLEX_HALF: /* not supported */
default:
e_err(probe, "Unsupported Speed/Duplex configuration\n");
return -EINVAL;
goto err_inval;
}
return 0;

err_inval:
e_err(probe, "Unsupported Speed/Duplex configuration\n");
return -EINVAL;
}

static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
Expand Down
24 changes: 16 additions & 8 deletions trunk/drivers/net/e1000e/ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,25 @@ static int e1000_get_settings(struct net_device *netdev,
return 0;
}

static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx)
{
struct e1000_mac_info *mac = &adapter->hw.mac;

mac->autoneg = 0;

/* Make sure dplx is at most 1 bit and lsb of speed is not set
* for the switch() below to work */
if ((spd & 1) || (dplx & ~1))
goto err_inval;

/* Fiber NICs only allow 1000 gbps Full duplex */
if ((adapter->hw.phy.media_type == e1000_media_type_fiber) &&
spddplx != (SPEED_1000 + DUPLEX_FULL)) {
e_err("Unsupported Speed/Duplex configuration\n");
return -EINVAL;
spd != SPEED_1000 &&
dplx != DUPLEX_FULL) {
goto err_inval;
}

switch (spddplx) {
switch (spd + dplx) {
case SPEED_10 + DUPLEX_HALF:
mac->forced_speed_duplex = ADVERTISE_10_HALF;
break;
Expand All @@ -232,10 +237,13 @@ static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
break;
case SPEED_1000 + DUPLEX_HALF: /* not supported */
default:
e_err("Unsupported Speed/Duplex configuration\n");
return -EINVAL;
goto err_inval;
}
return 0;

err_inval:
e_err("Unsupported Speed/Duplex configuration\n");
return -EINVAL;
}

static int e1000_set_settings(struct net_device *netdev,
Expand Down Expand Up @@ -272,7 +280,7 @@ static int e1000_set_settings(struct net_device *netdev,
hw->fc.requested_mode = e1000_fc_default;
} else {
u32 speed = ethtool_cmd_speed(ecmd);
if (e1000_set_spd_dplx(adapter, speed + ecmd->duplex)) {
if (e1000_set_spd_dplx(adapter, speed, ecmd->duplex)) {
clear_bit(__E1000_RESETTING, &adapter->state);
return -EINVAL;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/igb/igb.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ extern int igb_up(struct igb_adapter *);
extern void igb_down(struct igb_adapter *);
extern void igb_reinit_locked(struct igb_adapter *);
extern void igb_reset(struct igb_adapter *);
extern int igb_set_spd_dplx(struct igb_adapter *, u16);
extern int igb_set_spd_dplx(struct igb_adapter *, u32, u8);
extern int igb_setup_tx_resources(struct igb_ring *);
extern int igb_setup_rx_resources(struct igb_ring *);
extern void igb_free_tx_resources(struct igb_ring *);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/igb/igb_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static int igb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
hw->fc.requested_mode = e1000_fc_default;
} else {
u32 speed = ethtool_cmd_speed(ecmd);
if (igb_set_spd_dplx(adapter, speed + ecmd->duplex)) {
if (igb_set_spd_dplx(adapter, speed, ecmd->duplex)) {
clear_bit(__IGB_RESETTING, &adapter->state);
return -EINVAL;
}
Expand Down
23 changes: 15 additions & 8 deletions trunk/drivers/net/igb/igb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6349,21 +6349,25 @@ static void igb_restore_vlan(struct igb_adapter *adapter)
}
}

int igb_set_spd_dplx(struct igb_adapter *adapter, u16 spddplx)
int igb_set_spd_dplx(struct igb_adapter *adapter, u32 spd, u8 dplx)
{
struct pci_dev *pdev = adapter->pdev;
struct e1000_mac_info *mac = &adapter->hw.mac;

mac->autoneg = 0;

/* Make sure dplx is at most 1 bit and lsb of speed is not set
* for the switch() below to work */
if ((spd & 1) || (dplx & ~1))
goto err_inval;

/* Fiber NIC's only allow 1000 Gbps Full duplex */
if ((adapter->hw.phy.media_type == e1000_media_type_internal_serdes) &&
spddplx != (SPEED_1000 + DUPLEX_FULL)) {
dev_err(&pdev->dev, "Unsupported Speed/Duplex configuration\n");
return -EINVAL;
}
spd != SPEED_1000 &&
dplx != DUPLEX_FULL)
goto err_inval;

switch (spddplx) {
switch (spd + dplx) {
case SPEED_10 + DUPLEX_HALF:
mac->forced_speed_duplex = ADVERTISE_10_HALF;
break;
Expand All @@ -6382,10 +6386,13 @@ int igb_set_spd_dplx(struct igb_adapter *adapter, u16 spddplx)
break;
case SPEED_1000 + DUPLEX_HALF: /* not supported */
default:
dev_err(&pdev->dev, "Unsupported Speed/Duplex configuration\n");
return -EINVAL;
goto err_inval;
}
return 0;

err_inval:
dev_err(&pdev->dev, "Unsupported Speed/Duplex configuration\n");
return -EINVAL;
}

static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake)
Expand Down

0 comments on commit ce5cd91

Please sign in to comment.