From: Dale Farnsworth <[EMAIL PROTECTED]>

Remove duplicated code by having unicast and multicast code use
a common filter table function: eth_port_set_filter_table_entry().

Signed-off-by: Dale Farnsworth <[EMAIL PROTECTED]>

 drivers/net/mv643xx_eth.c |   84 ++++------------------------------------------
 drivers/net/mv643xx_eth.h |    4 --
 2 files changed, 9 insertions(+), 79 deletions(-)

Index: linux-2.6-mv643xx_enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.6-mv643xx_enet.orig/drivers/net/mv643xx_eth.c       2006-01-17 
15:42:36.000000000 -0700
+++ linux-2.6-mv643xx_enet/drivers/net/mv643xx_eth.c    2006-01-17 
15:44:50.000000000 -0700
@@ -1735,8 +1735,7 @@
 static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr);
 
 /* Ethernet Port routines */
-static int eth_port_uc_addr(unsigned int eth_port_num, unsigned char uc_nibble,
-                                                               int option);
+static void eth_port_set_filter_table_entry(int table, unsigned char entry);
 
 /*
  * eth_port_init - Initialize the Ethernet port driver
@@ -1864,8 +1863,9 @@
  *     char *          p_addr          Address to be set
  *
  * OUTPUT:
- *     Set MAC address low and high registers. also calls eth_port_uc_addr()
- *     To set the unicast table with the proper information.
+ *     Set MAC address low and high registers. also calls
+ *     eth_port_set_filter_table_entry() to set the unicast
+ *     table with the proper information.
  *
  * RETURN:
  *     N/A.
@@ -1876,6 +1876,7 @@
 {
        unsigned int mac_h;
        unsigned int mac_l;
+       int table;
 
        mac_l = (p_addr[4] << 8) | (p_addr[5]);
        mac_h = (p_addr[0] << 24) | (p_addr[1] << 16) | (p_addr[2] << 8) |
@@ -1885,9 +1886,8 @@
        mv_write(MV643XX_ETH_MAC_ADDR_HIGH(eth_port_num), mac_h);
 
        /* Accept frames of this address */
-       eth_port_uc_addr(eth_port_num, p_addr[5], ACCEPT_MAC_ADDR);
-
-       return;
+       table = MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE(eth_port_num);
+       eth_port_set_filter_table_entry(table, p_addr[5] & 0x0f);
 }
 
 /*
@@ -1926,72 +1926,6 @@
 }
 
 /*
- * eth_port_uc_addr - This function Set the port unicast address table
- *
- * DESCRIPTION:
- *     This function locates the proper entry in the Unicast table for the
- *     specified MAC nibble and sets its properties according to function
- *     parameters.
- *
- * INPUT:
- *     unsigned int    eth_port_num    Port number.
- *     unsigned char   uc_nibble       Unicast MAC Address last nibble.
- *     int             option          0 = Add, 1 = remove address.
- *
- * OUTPUT:
- *     This function add/removes MAC addresses from the port unicast address
- *     table.
- *
- * RETURN:
- *     true is output succeeded.
- *     false if option parameter is invalid.
- *
- */
-static int eth_port_uc_addr(unsigned int eth_port_num, unsigned char uc_nibble,
-                                                               int option)
-{
-       unsigned int unicast_reg;
-       unsigned int tbl_offset;
-       unsigned int reg_offset;
-
-       /* Locate the Unicast table entry */
-       uc_nibble = (0xf & uc_nibble);
-       tbl_offset = (uc_nibble / 4) * 4;       /* Register offset from unicast 
table base */
-       reg_offset = uc_nibble % 4;     /* Entry offset within the above 
register */
-
-       switch (option) {
-       case REJECT_MAC_ADDR:
-               /* Clear accepts frame bit at given unicast DA table entry */
-               unicast_reg = mv_read((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
-                                               (eth_port_num) + tbl_offset));
-
-               unicast_reg &= (0x0E << (8 * reg_offset));
-
-               mv_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
-                               (eth_port_num) + tbl_offset), unicast_reg);
-               break;
-
-       case ACCEPT_MAC_ADDR:
-               /* Set accepts frame bit at unicast DA filter table entry */
-               unicast_reg =
-                       mv_read((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
-                                               (eth_port_num) + tbl_offset));
-
-               unicast_reg |= (0x01 << (8 * reg_offset));
-
-               mv_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
-                               (eth_port_num) + tbl_offset), unicast_reg);
-
-               break;
-
-       default:
-               return 0;
-       }
-
-       return 1;
-}
-
-/*
  * The entries in each table are indexed by a hash of a packet's MAC
  * address.  One bit in each entry determines whether the packet is
  * accepted.  There are 4 entries (each 8 bits wide) in each register
@@ -2203,8 +2137,8 @@
 
        /* Clear DA filter unicast table (Ex_dFUT) */
        for (table_index = 0; table_index <= 0xC; table_index += 4)
-               mv_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
-                                       (eth_port_num) + table_index), 0);
+               mv_write(MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
+                                       (eth_port_num) + table_index, 0);
 
        for (table_index = 0; table_index <= 0xFC; table_index += 4) {
                /* Clear DA filter special multicast table (Ex_dFSMT) */
Index: linux-2.6-mv643xx_enet/drivers/net/mv643xx_eth.h
===================================================================
--- linux-2.6-mv643xx_enet.orig/drivers/net/mv643xx_eth.h       2006-01-17 
15:23:20.000000000 -0700
+++ linux-2.6-mv643xx_enet/drivers/net/mv643xx_eth.h    2006-01-17 
15:44:18.000000000 -0700
@@ -89,10 +89,6 @@
  *
  */
 
-/* MAC accepet/reject macros */
-#define ACCEPT_MAC_ADDR                                0
-#define REJECT_MAC_ADDR                                1
-
 /* Buffer offset from buffer pointer */
 #define RX_BUF_OFFSET                          0x2
 

-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to