diff options
Diffstat (limited to 'drivers/net/ucc_geth.c')
-rw-r--r-- | drivers/net/ucc_geth.c | 262 |
1 files changed, 0 insertions, 262 deletions
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c index defdad445ec..5c82f147f15 100644 --- a/drivers/net/ucc_geth.c +++ b/drivers/net/ucc_geth.c | |||
@@ -188,17 +188,6 @@ static void mem_disp(u8 *addr, int size) | |||
188 | } | 188 | } |
189 | #endif /* DEBUG */ | 189 | #endif /* DEBUG */ |
190 | 190 | ||
191 | #ifdef CONFIG_UGETH_FILTERING | ||
192 | static void enqueue(struct list_head *node, struct list_head *lh) | ||
193 | { | ||
194 | unsigned long flags; | ||
195 | |||
196 | spin_lock_irqsave(&ugeth_lock, flags); | ||
197 | list_add_tail(node, lh); | ||
198 | spin_unlock_irqrestore(&ugeth_lock, flags); | ||
199 | } | ||
200 | #endif /* CONFIG_UGETH_FILTERING */ | ||
201 | |||
202 | static struct list_head *dequeue(struct list_head *lh) | 191 | static struct list_head *dequeue(struct list_head *lh) |
203 | { | 192 | { |
204 | unsigned long flags; | 193 | unsigned long flags; |
@@ -391,23 +380,6 @@ static int dump_init_enet_entries(struct ucc_geth_private *ugeth, | |||
391 | } | 380 | } |
392 | #endif | 381 | #endif |
393 | 382 | ||
394 | #ifdef CONFIG_UGETH_FILTERING | ||
395 | static struct enet_addr_container *get_enet_addr_container(void) | ||
396 | { | ||
397 | struct enet_addr_container *enet_addr_cont; | ||
398 | |||
399 | /* allocate memory */ | ||
400 | enet_addr_cont = kmalloc(sizeof(struct enet_addr_container), GFP_KERNEL); | ||
401 | if (!enet_addr_cont) { | ||
402 | ugeth_err("%s: No memory for enet_addr_container object.", | ||
403 | __func__); | ||
404 | return NULL; | ||
405 | } | ||
406 | |||
407 | return enet_addr_cont; | ||
408 | } | ||
409 | #endif /* CONFIG_UGETH_FILTERING */ | ||
410 | |||
411 | static void put_enet_addr_container(struct enet_addr_container *enet_addr_cont) | 383 | static void put_enet_addr_container(struct enet_addr_container *enet_addr_cont) |
412 | { | 384 | { |
413 | kfree(enet_addr_cont); | 385 | kfree(enet_addr_cont); |
@@ -420,28 +392,6 @@ static void set_mac_addr(__be16 __iomem *reg, u8 *mac) | |||
420 | out_be16(®[2], ((u16)mac[1] << 8) | mac[0]); | 392 | out_be16(®[2], ((u16)mac[1] << 8) | mac[0]); |
421 | } | 393 | } |
422 | 394 | ||
423 | #ifdef CONFIG_UGETH_FILTERING | ||
424 | static int hw_add_addr_in_paddr(struct ucc_geth_private *ugeth, | ||
425 | u8 *p_enet_addr, u8 paddr_num) | ||
426 | { | ||
427 | struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt; | ||
428 | |||
429 | if (!(paddr_num < NUM_OF_PADDRS)) { | ||
430 | ugeth_warn("%s: Illegal paddr_num.", __func__); | ||
431 | return -EINVAL; | ||
432 | } | ||
433 | |||
434 | p_82xx_addr_filt = | ||
435 | (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram-> | ||
436 | addressfiltering; | ||
437 | |||
438 | /* Ethernet frames are defined in Little Endian mode, */ | ||
439 | /* therefore to insert the address we reverse the bytes. */ | ||
440 | set_mac_addr(&p_82xx_addr_filt->paddr[paddr_num].h, p_enet_addr); | ||
441 | return 0; | ||
442 | } | ||
443 | #endif /* CONFIG_UGETH_FILTERING */ | ||
444 | |||
445 | static int hw_clear_addr_in_paddr(struct ucc_geth_private *ugeth, u8 paddr_num) | 395 | static int hw_clear_addr_in_paddr(struct ucc_geth_private *ugeth, u8 paddr_num) |
446 | { | 396 | { |
447 | struct ucc_geth_82xx_address_filtering_pram __iomem *p_82xx_addr_filt; | 397 | struct ucc_geth_82xx_address_filtering_pram __iomem *p_82xx_addr_filt; |
@@ -1802,196 +1752,6 @@ static void ugeth_dump_regs(struct ucc_geth_private *ugeth) | |||
1802 | #endif | 1752 | #endif |
1803 | } | 1753 | } |
1804 | 1754 | ||
1805 | #ifdef CONFIG_UGETH_FILTERING | ||
1806 | static int ugeth_ext_filtering_serialize_tad(struct ucc_geth_tad_params * | ||
1807 | p_UccGethTadParams, | ||
1808 | struct qe_fltr_tad *qe_fltr_tad) | ||
1809 | { | ||
1810 | u16 temp; | ||
1811 | |||
1812 | /* Zero serialized TAD */ | ||
1813 | memset(qe_fltr_tad, 0, QE_FLTR_TAD_SIZE); | ||
1814 | |||
1815 | qe_fltr_tad->serialized[0] |= UCC_GETH_TAD_V; /* Must have this */ | ||
1816 | if (p_UccGethTadParams->rx_non_dynamic_extended_features_mode || | ||
1817 | (p_UccGethTadParams->vtag_op != UCC_GETH_VLAN_OPERATION_TAGGED_NOP) | ||
1818 | || (p_UccGethTadParams->vnontag_op != | ||
1819 | UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP) | ||
1820 | ) | ||
1821 | qe_fltr_tad->serialized[0] |= UCC_GETH_TAD_EF; | ||
1822 | if (p_UccGethTadParams->reject_frame) | ||
1823 | qe_fltr_tad->serialized[0] |= UCC_GETH_TAD_REJ; | ||
1824 | temp = | ||
1825 | (u16) (((u16) p_UccGethTadParams-> | ||
1826 | vtag_op) << UCC_GETH_TAD_VTAG_OP_SHIFT); | ||
1827 | qe_fltr_tad->serialized[0] |= (u8) (temp >> 8); /* upper bits */ | ||
1828 | |||
1829 | qe_fltr_tad->serialized[1] |= (u8) (temp & 0x00ff); /* lower bits */ | ||
1830 | if (p_UccGethTadParams->vnontag_op == | ||
1831 | UCC_GETH_VLAN_OPERATION_NON_TAGGED_Q_TAG_INSERT) | ||
1832 | qe_fltr_tad->serialized[1] |= UCC_GETH_TAD_V_NON_VTAG_OP; | ||
1833 | qe_fltr_tad->serialized[1] |= | ||
1834 | p_UccGethTadParams->rqos << UCC_GETH_TAD_RQOS_SHIFT; | ||
1835 | |||
1836 | qe_fltr_tad->serialized[2] |= | ||
1837 | p_UccGethTadParams->vpri << UCC_GETH_TAD_V_PRIORITY_SHIFT; | ||
1838 | /* upper bits */ | ||
1839 | qe_fltr_tad->serialized[2] |= (u8) (p_UccGethTadParams->vid >> 8); | ||
1840 | /* lower bits */ | ||
1841 | qe_fltr_tad->serialized[3] |= (u8) (p_UccGethTadParams->vid & 0x00ff); | ||
1842 | |||
1843 | return 0; | ||
1844 | } | ||
1845 | |||
1846 | static struct enet_addr_container_t | ||
1847 | *ugeth_82xx_filtering_get_match_addr_in_hash(struct ucc_geth_private *ugeth, | ||
1848 | struct enet_addr *p_enet_addr) | ||
1849 | { | ||
1850 | struct enet_addr_container *enet_addr_cont; | ||
1851 | struct list_head *p_lh; | ||
1852 | u16 i, num; | ||
1853 | int32_t j; | ||
1854 | u8 *p_counter; | ||
1855 | |||
1856 | if ((*p_enet_addr)[0] & ENET_GROUP_ADDR) { | ||
1857 | p_lh = &ugeth->group_hash_q; | ||
1858 | p_counter = &(ugeth->numGroupAddrInHash); | ||
1859 | } else { | ||
1860 | p_lh = &ugeth->ind_hash_q; | ||
1861 | p_counter = &(ugeth->numIndAddrInHash); | ||
1862 | } | ||
1863 | |||
1864 | if (!p_lh) | ||
1865 | return NULL; | ||
1866 | |||
1867 | num = *p_counter; | ||
1868 | |||
1869 | for (i = 0; i < num; i++) { | ||
1870 | enet_addr_cont = | ||
1871 | (struct enet_addr_container *) | ||
1872 | ENET_ADDR_CONT_ENTRY(dequeue(p_lh)); | ||
1873 | for (j = ENET_NUM_OCTETS_PER_ADDRESS - 1; j >= 0; j--) { | ||
1874 | if ((*p_enet_addr)[j] != (enet_addr_cont->address)[j]) | ||
1875 | break; | ||
1876 | if (j == 0) | ||
1877 | return enet_addr_cont; /* Found */ | ||
1878 | } | ||
1879 | enqueue(p_lh, &enet_addr_cont->node); /* Put it back */ | ||
1880 | } | ||
1881 | return NULL; | ||
1882 | } | ||
1883 | |||
1884 | static int ugeth_82xx_filtering_add_addr_in_hash(struct ucc_geth_private *ugeth, | ||
1885 | struct enet_addr *p_enet_addr) | ||
1886 | { | ||
1887 | enum ucc_geth_enet_address_recognition_location location; | ||
1888 | struct enet_addr_container *enet_addr_cont; | ||
1889 | struct list_head *p_lh; | ||
1890 | u8 i; | ||
1891 | u32 limit; | ||
1892 | u8 *p_counter; | ||
1893 | |||
1894 | if ((*p_enet_addr)[0] & ENET_GROUP_ADDR) { | ||
1895 | p_lh = &ugeth->group_hash_q; | ||
1896 | limit = ugeth->ug_info->maxGroupAddrInHash; | ||
1897 | location = | ||
1898 | UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_GROUP_HASH; | ||
1899 | p_counter = &(ugeth->numGroupAddrInHash); | ||
1900 | } else { | ||
1901 | p_lh = &ugeth->ind_hash_q; | ||
1902 | limit = ugeth->ug_info->maxIndAddrInHash; | ||
1903 | location = | ||
1904 | UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_INDIVIDUAL_HASH; | ||
1905 | p_counter = &(ugeth->numIndAddrInHash); | ||
1906 | } | ||
1907 | |||
1908 | if ((enet_addr_cont = | ||
1909 | ugeth_82xx_filtering_get_match_addr_in_hash(ugeth, p_enet_addr))) { | ||
1910 | list_add(p_lh, &enet_addr_cont->node); /* Put it back */ | ||
1911 | return 0; | ||
1912 | } | ||
1913 | if ((!p_lh) || (!(*p_counter < limit))) | ||
1914 | return -EBUSY; | ||
1915 | if (!(enet_addr_cont = get_enet_addr_container())) | ||
1916 | return -ENOMEM; | ||
1917 | for (i = 0; i < ENET_NUM_OCTETS_PER_ADDRESS; i++) | ||
1918 | (enet_addr_cont->address)[i] = (*p_enet_addr)[i]; | ||
1919 | enet_addr_cont->location = location; | ||
1920 | enqueue(p_lh, &enet_addr_cont->node); /* Put it back */ | ||
1921 | ++(*p_counter); | ||
1922 | |||
1923 | hw_add_addr_in_hash(ugeth, enet_addr_cont->address); | ||
1924 | return 0; | ||
1925 | } | ||
1926 | |||
1927 | static int ugeth_82xx_filtering_clear_addr_in_hash(struct ucc_geth_private *ugeth, | ||
1928 | struct enet_addr *p_enet_addr) | ||
1929 | { | ||
1930 | struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt; | ||
1931 | struct enet_addr_container *enet_addr_cont; | ||
1932 | struct ucc_fast_private *uccf; | ||
1933 | enum comm_dir comm_dir; | ||
1934 | u16 i, num; | ||
1935 | struct list_head *p_lh; | ||
1936 | u32 *addr_h, *addr_l; | ||
1937 | u8 *p_counter; | ||
1938 | |||
1939 | uccf = ugeth->uccf; | ||
1940 | |||
1941 | p_82xx_addr_filt = | ||
1942 | (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram-> | ||
1943 | addressfiltering; | ||
1944 | |||
1945 | if (! | ||
1946 | (enet_addr_cont = | ||
1947 | ugeth_82xx_filtering_get_match_addr_in_hash(ugeth, p_enet_addr))) | ||
1948 | return -ENOENT; | ||
1949 | |||
1950 | /* It's been found and removed from the CQ. */ | ||
1951 | /* Now destroy its container */ | ||
1952 | put_enet_addr_container(enet_addr_cont); | ||
1953 | |||
1954 | if ((*p_enet_addr)[0] & ENET_GROUP_ADDR) { | ||
1955 | addr_h = &(p_82xx_addr_filt->gaddr_h); | ||
1956 | addr_l = &(p_82xx_addr_filt->gaddr_l); | ||
1957 | p_lh = &ugeth->group_hash_q; | ||
1958 | p_counter = &(ugeth->numGroupAddrInHash); | ||
1959 | } else { | ||
1960 | addr_h = &(p_82xx_addr_filt->iaddr_h); | ||
1961 | addr_l = &(p_82xx_addr_filt->iaddr_l); | ||
1962 | p_lh = &ugeth->ind_hash_q; | ||
1963 | p_counter = &(ugeth->numIndAddrInHash); | ||
1964 | } | ||
1965 | |||
1966 | comm_dir = 0; | ||
1967 | if (uccf->enabled_tx) | ||
1968 | comm_dir |= COMM_DIR_TX; | ||
1969 | if (uccf->enabled_rx) | ||
1970 | comm_dir |= COMM_DIR_RX; | ||
1971 | if (comm_dir) | ||
1972 | ugeth_disable(ugeth, comm_dir); | ||
1973 | |||
1974 | /* Clear the hash table. */ | ||
1975 | out_be32(addr_h, 0x00000000); | ||
1976 | out_be32(addr_l, 0x00000000); | ||
1977 | |||
1978 | /* Add all remaining CQ elements back into hash */ | ||
1979 | num = --(*p_counter); | ||
1980 | for (i = 0; i < num; i++) { | ||
1981 | enet_addr_cont = | ||
1982 | (struct enet_addr_container *) | ||
1983 | ENET_ADDR_CONT_ENTRY(dequeue(p_lh)); | ||
1984 | hw_add_addr_in_hash(ugeth, enet_addr_cont->address); | ||
1985 | enqueue(p_lh, &enet_addr_cont->node); /* Put it back */ | ||
1986 | } | ||
1987 | |||
1988 | if (comm_dir) | ||
1989 | ugeth_enable(ugeth, comm_dir); | ||
1990 | |||
1991 | return 0; | ||
1992 | } | ||
1993 | #endif /* CONFIG_UGETH_FILTERING */ | ||
1994 | |||
1995 | static int ugeth_82xx_filtering_clear_all_addr_in_hash(struct ucc_geth_private * | 1755 | static int ugeth_82xx_filtering_clear_all_addr_in_hash(struct ucc_geth_private * |
1996 | ugeth, | 1756 | ugeth, |
1997 | enum enet_addr_type | 1757 | enum enet_addr_type |
@@ -2054,28 +1814,6 @@ static int ugeth_82xx_filtering_clear_all_addr_in_hash(struct ucc_geth_private * | |||
2054 | return 0; | 1814 | return 0; |
2055 | } | 1815 | } |
2056 | 1816 | ||
2057 | #ifdef CONFIG_UGETH_FILTERING | ||
2058 | static int ugeth_82xx_filtering_add_addr_in_paddr(struct ucc_geth_private *ugeth, | ||
2059 | struct enet_addr *p_enet_addr, | ||
2060 | u8 paddr_num) | ||
2061 | { | ||
2062 | int i; | ||
2063 | |||
2064 | if ((*p_enet_addr)[0] & ENET_GROUP_ADDR) | ||
2065 | ugeth_warn | ||
2066 | ("%s: multicast address added to paddr will have no " | ||
2067 | "effect - is this what you wanted?", | ||
2068 | __func__); | ||
2069 | |||
2070 | ugeth->indAddrRegUsed[paddr_num] = 1; /* mark this paddr as used */ | ||
2071 | /* store address in our database */ | ||
2072 | for (i = 0; i < ENET_NUM_OCTETS_PER_ADDRESS; i++) | ||
2073 | ugeth->paddr[paddr_num][i] = (*p_enet_addr)[i]; | ||
2074 | /* put in hardware */ | ||
2075 | return hw_add_addr_in_paddr(ugeth, p_enet_addr, paddr_num); | ||
2076 | } | ||
2077 | #endif /* CONFIG_UGETH_FILTERING */ | ||
2078 | |||
2079 | static int ugeth_82xx_filtering_clear_addr_in_paddr(struct ucc_geth_private *ugeth, | 1817 | static int ugeth_82xx_filtering_clear_addr_in_paddr(struct ucc_geth_private *ugeth, |
2080 | u8 paddr_num) | 1818 | u8 paddr_num) |
2081 | { | 1819 | { |