Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 352127
b: refs/heads/master
c: 2de27f3
h: refs/heads/master
i:
  352125: 7df8c2c
  352123: d526b73
  352119: f915e5c
  352111: 63b55a4
  352095: 050cf89
  352063: b5052ed
  351999: ce666a4
v: v3
  • Loading branch information
David S. Miller committed Feb 8, 2013
1 parent 85e2f22 commit 303694c
Show file tree
Hide file tree
Showing 22 changed files with 422 additions and 83 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: 0ccddcd1c2d93ff58b42115f19a0976394208d06
refs/heads/master: 2de27f307feda26ef364f2407b70e3ca02a3ce56
56 changes: 42 additions & 14 deletions trunk/drivers/net/ethernet/broadcom/bgmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,26 @@ static void bgmac_cmdcfg_maskset(struct bgmac *bgmac, u32 mask, u32 set,
udelay(2);
}

static void bgmac_write_mac_address(struct bgmac *bgmac, u8 *addr)
{
u32 tmp;

tmp = (addr[0] << 24) | (addr[1] << 16) | (addr[2] << 8) | addr[3];
bgmac_write(bgmac, BGMAC_MACADDR_HIGH, tmp);
tmp = (addr[4] << 8) | addr[5];
bgmac_write(bgmac, BGMAC_MACADDR_LOW, tmp);
}

static void bgmac_set_rx_mode(struct net_device *net_dev)
{
struct bgmac *bgmac = netdev_priv(net_dev);

if (net_dev->flags & IFF_PROMISC)
bgmac_cmdcfg_maskset(bgmac, ~0, BGMAC_CMDCFG_PROM, false);
else
bgmac_cmdcfg_maskset(bgmac, ~BGMAC_CMDCFG_PROM, 0, false);
}

#if 0 /* We don't use that regs yet */
static void bgmac_chip_stats_update(struct bgmac *bgmac)
{
Expand Down Expand Up @@ -889,8 +909,10 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
sw_type = et_swtype;
} else if (ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == 9) {
sw_type = BGMAC_CHIPCTL_1_SW_TYPE_EPHYRMII;
} else if (0) {
/* TODO */
} else if ((ci->id != BCMA_CHIP_ID_BCM53572 && ci->pkg == 10) ||
(ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == 9)) {
sw_type = BGMAC_CHIPCTL_1_IF_TYPE_RGMII |
BGMAC_CHIPCTL_1_SW_TYPE_RGMII;
}
bcma_chipco_chipctl_maskset(cc, 1,
~(BGMAC_CHIPCTL_1_IF_TYPE_MASK |
Expand Down Expand Up @@ -1004,8 +1026,6 @@ static void bgmac_enable(struct bgmac *bgmac)
static void bgmac_chip_init(struct bgmac *bgmac, bool full_init)
{
struct bgmac_dma_ring *ring;
u8 *mac = bgmac->net_dev->dev_addr;
u32 tmp;
int i;

/* 1 interrupt per received frame */
Expand All @@ -1014,16 +1034,9 @@ static void bgmac_chip_init(struct bgmac *bgmac, bool full_init)
/* Enable 802.3x tx flow control (honor received PAUSE frames) */
bgmac_cmdcfg_maskset(bgmac, ~BGMAC_CMDCFG_RPI, 0, true);

if (bgmac->net_dev->flags & IFF_PROMISC)
bgmac_cmdcfg_maskset(bgmac, ~0, BGMAC_CMDCFG_PROM, false);
else
bgmac_cmdcfg_maskset(bgmac, ~BGMAC_CMDCFG_PROM, 0, false);
bgmac_set_rx_mode(bgmac->net_dev);

/* Set MAC addr */
tmp = (mac[0] << 24) | (mac[1] << 16) | (mac[2] << 8) | mac[3];
bgmac_write(bgmac, BGMAC_MACADDR_HIGH, tmp);
tmp = (mac[4] << 8) | mac[5];
bgmac_write(bgmac, BGMAC_MACADDR_LOW, tmp);
bgmac_write_mac_address(bgmac, bgmac->net_dev->dev_addr);

if (bgmac->loopback)
bgmac_cmdcfg_maskset(bgmac, ~0, BGMAC_CMDCFG_ML, true);
Expand Down Expand Up @@ -1160,6 +1173,19 @@ static netdev_tx_t bgmac_start_xmit(struct sk_buff *skb,
return bgmac_dma_tx_add(bgmac, ring, skb);
}

static int bgmac_set_mac_address(struct net_device *net_dev, void *addr)
{
struct bgmac *bgmac = netdev_priv(net_dev);
int ret;

ret = eth_prepare_mac_addr_change(net_dev, addr);
if (ret < 0)
return ret;
bgmac_write_mac_address(bgmac, (u8 *)addr);
eth_commit_mac_addr_change(net_dev, addr);
return 0;
}

static int bgmac_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
{
struct bgmac *bgmac = netdev_priv(net_dev);
Expand Down Expand Up @@ -1190,7 +1216,9 @@ static const struct net_device_ops bgmac_netdev_ops = {
.ndo_open = bgmac_open,
.ndo_stop = bgmac_stop,
.ndo_start_xmit = bgmac_start_xmit,
.ndo_set_mac_address = eth_mac_addr, /* generic, sets dev_addr */
.ndo_set_rx_mode = bgmac_set_rx_mode,
.ndo_set_mac_address = bgmac_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = bgmac_ioctl,
};

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/ethernet/broadcom/bgmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
#define BGMAC_CHIPCTL_1_SW_TYPE_EPHY 0x00000000
#define BGMAC_CHIPCTL_1_SW_TYPE_EPHYMII 0x00000040
#define BGMAC_CHIPCTL_1_SW_TYPE_EPHYRMII 0x00000080
#define BGMAC_CHIPCTL_1_SW_TYPE_RGMI 0x000000C0
#define BGMAC_CHIPCTL_1_SW_TYPE_RGMII 0x000000C0
#define BGMAC_CHIPCTL_1_RXC_DLL_BYPASS 0x00010000

#define BGMAC_SPEED_10 0x0001
Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)

struct netxen_cmd_buffer *cmd_buf_arr;
struct net_device *netdev = adapter->netdev;
struct pci_dev *pdev = adapter->pdev;

tx_ring = kzalloc(sizeof(struct nx_host_tx_ring), GFP_KERNEL);
if (tx_ring == NULL)
Expand Down
114 changes: 108 additions & 6 deletions trunk/drivers/net/ethernet/ti/cpsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/of.h>
#include <linux/of_net.h>
#include <linux/of_device.h>
#include <linux/if_vlan.h>

#include <linux/platform_data/cpsw.h>

Expand Down Expand Up @@ -118,6 +119,9 @@ do { \
#define TX_PRIORITY_MAPPING 0x33221100
#define CPDMA_TX_PRIORITY_MAP 0x76543210

#define CPSW_VLAN_AWARE BIT(1)
#define CPSW_ALE_VLAN_AWARE 1

#define cpsw_enable_irq(priv) \
do { \
u32 i; \
Expand Down Expand Up @@ -345,7 +349,7 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev)
/* program multicast address list into ALE register */
netdev_for_each_mc_addr(ha, ndev) {
cpsw_ale_add_mcast(priv->ale, (u8 *)ha->addr,
ALE_ALL_PORTS << priv->host_port, 0, 0);
ALE_ALL_PORTS << priv->host_port, 0, 0, 0);
}
}
}
Expand Down Expand Up @@ -592,7 +596,7 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
slave_port = cpsw_get_slave_port(priv, slave->slave_num);

cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
1 << slave_port, 0, ALE_MCAST_FWD_2);
1 << slave_port, 0, 0, ALE_MCAST_FWD_2);

slave->phy = phy_connect(priv->ndev, slave->data->phy_id,
&cpsw_adjust_link, slave->data->phy_if);
Expand All @@ -607,14 +611,40 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
}
}

static inline void cpsw_add_default_vlan(struct cpsw_priv *priv)
{
const int vlan = priv->data.default_vlan;
const int port = priv->host_port;
u32 reg;
int i;

reg = (priv->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN :
CPSW2_PORT_VLAN;

writel(vlan, &priv->host_port_regs->port_vlan);

for (i = 0; i < 2; i++)
slave_write(priv->slaves + i, vlan, reg);

cpsw_ale_add_vlan(priv->ale, vlan, ALE_ALL_PORTS << port,
ALE_ALL_PORTS << port, ALE_ALL_PORTS << port,
(ALE_PORT_1 | ALE_PORT_2) << port);
}

static void cpsw_init_host_port(struct cpsw_priv *priv)
{
u32 control_reg;

/* soft reset the controller and initialize ale */
soft_reset("cpsw", &priv->regs->soft_reset);
cpsw_ale_start(priv->ale);

/* switch to vlan unaware mode */
cpsw_ale_control_set(priv->ale, 0, ALE_VLAN_AWARE, 0);
cpsw_ale_control_set(priv->ale, priv->host_port, ALE_VLAN_AWARE,
CPSW_ALE_VLAN_AWARE);
control_reg = readl(&priv->regs->control);
control_reg |= CPSW_VLAN_AWARE;
writel(control_reg, &priv->regs->control);

/* setup host port priority mapping */
__raw_writel(CPDMA_TX_PRIORITY_MAP,
Expand All @@ -624,9 +654,9 @@ static void cpsw_init_host_port(struct cpsw_priv *priv)
cpsw_ale_control_set(priv->ale, priv->host_port,
ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);

cpsw_ale_add_ucast(priv->ale, priv->mac_addr, priv->host_port, 0);
cpsw_ale_add_ucast(priv->ale, priv->mac_addr, priv->host_port, 0, 0);
cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
1 << priv->host_port, 0, ALE_MCAST_FWD_2);
1 << priv->host_port, 0, 0, ALE_MCAST_FWD_2);
}

static int cpsw_ndo_open(struct net_device *ndev)
Expand All @@ -650,6 +680,9 @@ static int cpsw_ndo_open(struct net_device *ndev)
cpsw_init_host_port(priv);
for_each_slave(priv, cpsw_slave_open, priv);

/* Add default VLAN */
cpsw_add_default_vlan(priv);

/* setup tx dma to fixed prio and zero offset */
cpdma_control_set(priv->dma, CPDMA_TX_PRIO_FIXED, 1);
cpdma_control_set(priv->dma, CPDMA_RX_BUFFER_OFFSET, 0);
Expand Down Expand Up @@ -933,6 +966,73 @@ static void cpsw_ndo_poll_controller(struct net_device *ndev)
}
#endif

static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv,
unsigned short vid)
{
int ret;

ret = cpsw_ale_add_vlan(priv->ale, vid,
ALE_ALL_PORTS << priv->host_port,
0, ALE_ALL_PORTS << priv->host_port,
(ALE_PORT_1 | ALE_PORT_2) << priv->host_port);
if (ret != 0)
return ret;

ret = cpsw_ale_add_ucast(priv->ale, priv->mac_addr,
priv->host_port, ALE_VLAN, vid);
if (ret != 0)
goto clean_vid;

ret = cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
ALE_ALL_PORTS << priv->host_port,
ALE_VLAN, vid, 0);
if (ret != 0)
goto clean_vlan_ucast;
return 0;

clean_vlan_ucast:
cpsw_ale_del_ucast(priv->ale, priv->mac_addr,
priv->host_port, ALE_VLAN, vid);
clean_vid:
cpsw_ale_del_vlan(priv->ale, vid, 0);
return ret;
}

static int cpsw_ndo_vlan_rx_add_vid(struct net_device *ndev,
unsigned short vid)
{
struct cpsw_priv *priv = netdev_priv(ndev);

if (vid == priv->data.default_vlan)
return 0;

dev_info(priv->dev, "Adding vlanid %d to vlan filter\n", vid);
return cpsw_add_vlan_ale_entry(priv, vid);
}

static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev,
unsigned short vid)
{
struct cpsw_priv *priv = netdev_priv(ndev);
int ret;

if (vid == priv->data.default_vlan)
return 0;

dev_info(priv->dev, "removing vlanid %d from vlan filter\n", vid);
ret = cpsw_ale_del_vlan(priv->ale, vid, 0);
if (ret != 0)
return ret;

ret = cpsw_ale_del_ucast(priv->ale, priv->mac_addr,
priv->host_port, ALE_VLAN, vid);
if (ret != 0)
return ret;

return cpsw_ale_del_mcast(priv->ale, priv->ndev->broadcast,
0, ALE_VLAN, vid);
}

static const struct net_device_ops cpsw_netdev_ops = {
.ndo_open = cpsw_ndo_open,
.ndo_stop = cpsw_ndo_stop,
Expand All @@ -947,6 +1047,8 @@ static const struct net_device_ops cpsw_netdev_ops = {
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = cpsw_ndo_poll_controller,
#endif
.ndo_vlan_rx_add_vid = cpsw_ndo_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = cpsw_ndo_vlan_rx_kill_vid,
};

static void cpsw_get_drvinfo(struct net_device *ndev,
Expand Down Expand Up @@ -1354,7 +1456,7 @@ static int cpsw_probe(struct platform_device *pdev)
k++;
}

ndev->flags |= IFF_ALLMULTI; /* see cpsw_ndo_change_rx_flags() */
ndev->features |= NETIF_F_HW_VLAN_FILTER;

ndev->netdev_ops = &cpsw_netdev_ops;
SET_ETHTOOL_OPS(ndev, &cpsw_ethtool_ops);
Expand Down
Loading

0 comments on commit 303694c

Please sign in to comment.