H A D | rocker.c | 2 * drivers/net/ethernet/rocker/rocker.c - Rocker switch device driver 42 #include "rocker.h" 44 static const char rocker_driver_name[] = "rocker"; 197 struct rocker; 216 struct rocker *rocker; member in struct:rocker_port 230 struct rocker { struct 377 static u32 rocker_msix_vector(struct rocker *rocker, unsigned int vector) rocker_msix_vector() argument 379 return rocker->msix_entries[vector].vector; rocker_msix_vector() 384 return rocker_msix_vector(rocker_port->rocker, rocker_msix_tx_vector() 390 return rocker_msix_vector(rocker_port->rocker, rocker_msix_rx_vector() 394 #define rocker_write32(rocker, reg, val) \ 395 writel((val), (rocker)->hw_addr + (ROCKER_ ## reg)) 396 #define rocker_read32(rocker, reg) \ 397 readl((rocker)->hw_addr + (ROCKER_ ## reg)) 398 #define rocker_write64(rocker, reg, val) \ 399 writeq((val), (rocker)->hw_addr + (ROCKER_ ## reg)) 400 #define rocker_read64(rocker, reg) \ 401 readq((rocker)->hw_addr + (ROCKER_ ## reg)) 407 static int rocker_reg_test(struct rocker *rocker) rocker_reg_test() argument 409 struct pci_dev *pdev = rocker->pdev; rocker_reg_test() 415 rocker_write32(rocker, TEST_REG, rnd); rocker_reg_test() 416 test_reg = rocker_read32(rocker, TEST_REG); rocker_reg_test() 426 rocker_write64(rocker, TEST_REG64, rnd); rocker_reg_test() 427 test_reg = rocker_read64(rocker, TEST_REG64); rocker_reg_test() 437 static int rocker_dma_test_one(struct rocker *rocker, struct rocker_wait *wait, rocker_dma_test_one() argument 442 struct pci_dev *pdev = rocker->pdev; rocker_dma_test_one() 446 rocker_write32(rocker, TEST_DMA_CTRL, test_type); rocker_dma_test_one() 466 static int rocker_dma_test_offset(struct rocker *rocker, rocker_dma_test_offset() argument 469 struct pci_dev *pdev = rocker->pdev; rocker_dma_test_offset() 491 rocker_write64(rocker, TEST_DMA_ADDR, dma_handle); rocker_dma_test_offset() 492 rocker_write32(rocker, TEST_DMA_SIZE, ROCKER_TEST_DMA_BUF_SIZE); rocker_dma_test_offset() 495 err = rocker_dma_test_one(rocker, wait, ROCKER_TEST_DMA_CTRL_FILL, rocker_dma_test_offset() 502 err = rocker_dma_test_one(rocker, wait, ROCKER_TEST_DMA_CTRL_CLEAR, rocker_dma_test_offset() 511 err = rocker_dma_test_one(rocker, wait, ROCKER_TEST_DMA_CTRL_INVERT, rocker_dma_test_offset() 526 static int rocker_dma_test(struct rocker *rocker, struct rocker_wait *wait) rocker_dma_test() argument 532 err = rocker_dma_test_offset(rocker, wait, i); rocker_dma_test() 548 static int rocker_basic_hw_test(struct rocker *rocker) rocker_basic_hw_test() argument 550 struct pci_dev *pdev = rocker->pdev; rocker_basic_hw_test() 554 err = rocker_reg_test(rocker); rocker_basic_hw_test() 560 err = request_irq(rocker_msix_vector(rocker, ROCKER_MSIX_VEC_TEST), rocker_basic_hw_test() 569 rocker_write32(rocker, TEST_IRQ, ROCKER_MSIX_VEC_TEST); rocker_basic_hw_test() 577 err = rocker_dma_test(rocker, &wait); rocker_basic_hw_test() 582 free_irq(rocker_msix_vector(rocker, ROCKER_MSIX_VEC_TEST), &wait); rocker_basic_hw_test() 877 static void rocker_desc_head_set(struct rocker *rocker, rocker_desc_head_set() argument 886 rocker_write32(rocker, DMA_DESC_HEAD(info->type), head); rocker_desc_head_set() 904 static void rocker_dma_ring_credits_set(struct rocker *rocker, rocker_dma_ring_credits_set() argument 909 rocker_write32(rocker, DMA_DESC_CREDITS(info->type), credits); rocker_dma_ring_credits_set() 918 static int rocker_dma_ring_create(struct rocker *rocker, rocker_dma_ring_create() argument 935 info->desc = pci_alloc_consistent(rocker->pdev, rocker_dma_ring_create() 946 rocker_write32(rocker, DMA_DESC_CTRL(info->type), rocker_dma_ring_create() 948 rocker_write64(rocker, DMA_DESC_ADDR(info->type), info->mapaddr); rocker_dma_ring_create() 949 rocker_write32(rocker, DMA_DESC_SIZE(info->type), info->size); rocker_dma_ring_create() 954 static void rocker_dma_ring_destroy(struct rocker *rocker, rocker_dma_ring_destroy() argument 957 rocker_write64(rocker, DMA_DESC_ADDR(info->type), 0); rocker_dma_ring_destroy() 959 pci_free_consistent(rocker->pdev, rocker_dma_ring_destroy() 965 static void rocker_dma_ring_pass_to_producer(struct rocker *rocker, rocker_dma_ring_pass_to_producer() argument 976 rocker_desc_head_set(rocker, info, &info->desc_info[i]); rocker_dma_ring_pass_to_producer() 980 static int rocker_dma_ring_bufs_alloc(struct rocker *rocker, rocker_dma_ring_bufs_alloc() argument 984 struct pci_dev *pdev = rocker->pdev; rocker_dma_ring_bufs_alloc() 1027 static void rocker_dma_ring_bufs_free(struct rocker *rocker, rocker_dma_ring_bufs_free() argument 1031 struct pci_dev *pdev = rocker->pdev; rocker_dma_ring_bufs_free() 1046 static int rocker_dma_rings_init(struct rocker *rocker) rocker_dma_rings_init() argument 1048 struct pci_dev *pdev = rocker->pdev; rocker_dma_rings_init() 1051 err = rocker_dma_ring_create(rocker, ROCKER_DMA_CMD, rocker_dma_rings_init() 1053 &rocker->cmd_ring); rocker_dma_rings_init() 1059 spin_lock_init(&rocker->cmd_ring_lock); rocker_dma_rings_init() 1061 err = rocker_dma_ring_bufs_alloc(rocker, &rocker->cmd_ring, rocker_dma_rings_init() 1068 err = rocker_dma_ring_create(rocker, ROCKER_DMA_EVENT, rocker_dma_rings_init() 1070 &rocker->event_ring); rocker_dma_rings_init() 1076 err = rocker_dma_ring_bufs_alloc(rocker, &rocker->event_ring, rocker_dma_rings_init() 1082 rocker_dma_ring_pass_to_producer(rocker, &rocker->event_ring); rocker_dma_rings_init() 1086 rocker_dma_ring_destroy(rocker, &rocker->event_ring); rocker_dma_rings_init() 1088 rocker_dma_ring_bufs_free(rocker, &rocker->cmd_ring, rocker_dma_rings_init() 1091 rocker_dma_ring_destroy(rocker, &rocker->cmd_ring); rocker_dma_rings_init() 1095 static void rocker_dma_rings_fini(struct rocker *rocker) rocker_dma_rings_fini() argument 1097 rocker_dma_ring_bufs_free(rocker, &rocker->event_ring, rocker_dma_rings_fini() 1099 rocker_dma_ring_destroy(rocker, &rocker->event_ring); rocker_dma_rings_fini() 1100 rocker_dma_ring_bufs_free(rocker, &rocker->cmd_ring, rocker_dma_rings_fini() 1102 rocker_dma_ring_destroy(rocker, &rocker->cmd_ring); rocker_dma_rings_fini() 1105 static int rocker_dma_rx_ring_skb_map(struct rocker *rocker, rocker_dma_rx_ring_skb_map() argument 1110 struct pci_dev *pdev = rocker->pdev; rocker_dma_rx_ring_skb_map() 1134 static int rocker_dma_rx_ring_skb_alloc(struct rocker *rocker, rocker_dma_rx_ring_skb_alloc() argument 1152 err = rocker_dma_rx_ring_skb_map(rocker, rocker_port, desc_info, rocker_dma_rx_ring_skb_alloc() 1162 static void rocker_dma_rx_ring_skb_unmap(struct rocker *rocker, rocker_dma_rx_ring_skb_unmap() argument 1165 struct pci_dev *pdev = rocker->pdev; rocker_dma_rx_ring_skb_unmap() 1177 static void rocker_dma_rx_ring_skb_free(struct rocker *rocker, rocker_dma_rx_ring_skb_free() argument 1186 rocker_dma_rx_ring_skb_unmap(rocker, attrs); rocker_dma_rx_ring_skb_free() 1190 static int rocker_dma_rx_ring_skbs_alloc(struct rocker *rocker, rocker_dma_rx_ring_skbs_alloc() argument 1198 err = rocker_dma_rx_ring_skb_alloc(rocker, rocker_port, rocker_dma_rx_ring_skbs_alloc() 1207 rocker_dma_rx_ring_skb_free(rocker, &rx_ring->desc_info[i]); rocker_dma_rx_ring_skbs_alloc() 1211 static void rocker_dma_rx_ring_skbs_free(struct rocker *rocker, rocker_dma_rx_ring_skbs_free() argument 1218 rocker_dma_rx_ring_skb_free(rocker, &rx_ring->desc_info[i]); rocker_dma_rx_ring_skbs_free() 1223 struct rocker *rocker = rocker_port->rocker; rocker_port_dma_rings_init() local 1226 err = rocker_dma_ring_create(rocker, rocker_port_dma_rings_init() 1235 err = rocker_dma_ring_bufs_alloc(rocker, &rocker_port->tx_ring, rocker_port_dma_rings_init() 1243 err = rocker_dma_ring_create(rocker, rocker_port_dma_rings_init() 1252 err = rocker_dma_ring_bufs_alloc(rocker, &rocker_port->rx_ring, rocker_port_dma_rings_init() 1260 err = rocker_dma_rx_ring_skbs_alloc(rocker, rocker_port); rocker_port_dma_rings_init() 1265 rocker_dma_ring_pass_to_producer(rocker, &rocker_port->rx_ring); rocker_port_dma_rings_init() 1270 rocker_dma_ring_bufs_free(rocker, &rocker_port->rx_ring, rocker_port_dma_rings_init() 1273 rocker_dma_ring_destroy(rocker, &rocker_port->rx_ring); rocker_port_dma_rings_init() 1275 rocker_dma_ring_bufs_free(rocker, &rocker_port->tx_ring, rocker_port_dma_rings_init() 1278 rocker_dma_ring_destroy(rocker, &rocker_port->tx_ring); rocker_port_dma_rings_init() 1284 struct rocker *rocker = rocker_port->rocker; rocker_port_dma_rings_fini() local 1286 rocker_dma_rx_ring_skbs_free(rocker, rocker_port); rocker_port_dma_rings_fini() 1287 rocker_dma_ring_bufs_free(rocker, &rocker_port->rx_ring, rocker_port_dma_rings_fini() 1289 rocker_dma_ring_destroy(rocker, &rocker_port->rx_ring); rocker_port_dma_rings_fini() 1290 rocker_dma_ring_bufs_free(rocker, &rocker_port->tx_ring, rocker_port_dma_rings_fini() 1292 rocker_dma_ring_destroy(rocker, &rocker_port->tx_ring); rocker_port_dma_rings_fini() 1297 u64 val = rocker_read64(rocker_port->rocker, PORT_PHYS_ENABLE); rocker_port_set_enable() 1303 rocker_write64(rocker_port->rocker, PORT_PHYS_ENABLE, val); rocker_port_set_enable() 1312 struct rocker *rocker = dev_id; rocker_cmd_irq_handler() local 1317 spin_lock(&rocker->cmd_ring_lock); rocker_cmd_irq_handler() 1318 while ((desc_info = rocker_desc_tail_get(&rocker->cmd_ring))) { rocker_cmd_irq_handler() 1328 spin_unlock(&rocker->cmd_ring_lock); rocker_cmd_irq_handler() 1329 rocker_dma_ring_credits_set(rocker, &rocker->cmd_ring, credits); rocker_cmd_irq_handler() 1346 static int rocker_event_link_change(struct rocker *rocker, rocker_event_link_change() argument 1362 if (port_number >= rocker->port_count) rocker_event_link_change() 1365 rocker_port = rocker->ports[port_number]; rocker_event_link_change() 1385 static int rocker_event_mac_vlan_seen(struct rocker *rocker, rocker_event_mac_vlan_seen() argument 1405 if (port_number >= rocker->port_count) rocker_event_mac_vlan_seen() 1408 rocker_port = rocker->ports[port_number]; rocker_event_mac_vlan_seen() 1417 static int rocker_event_process(struct rocker *rocker, rocker_event_process() argument 1434 return rocker_event_link_change(rocker, info); rocker_event_process() 1436 return rocker_event_mac_vlan_seen(rocker, info); rocker_event_process() 1444 struct rocker *rocker = dev_id; rocker_event_irq_handler() local 1445 struct pci_dev *pdev = rocker->pdev; rocker_event_irq_handler() 1450 while ((desc_info = rocker_desc_tail_get(&rocker->event_ring))) { rocker_event_irq_handler() 1456 err = rocker_event_process(rocker, desc_info); rocker_event_irq_handler() 1462 rocker_desc_head_set(rocker, &rocker->event_ring, desc_info); rocker_event_irq_handler() 1465 rocker_dma_ring_credits_set(rocker, &rocker->event_ring, credits); rocker_event_irq_handler() 1490 typedef int (*rocker_cmd_cb_t)(struct rocker *rocker, 1495 static int rocker_cmd_exec(struct rocker *rocker, rocker_cmd_exec() argument 1511 spin_lock_irqsave(&rocker->cmd_ring_lock, flags); rocker_cmd_exec() 1512 desc_info = rocker_desc_head_get(&rocker->cmd_ring); rocker_cmd_exec() 1514 spin_unlock_irqrestore(&rocker->cmd_ring_lock, flags); rocker_cmd_exec() 1518 err = prepare(rocker, rocker_port, desc_info, prepare_priv); rocker_cmd_exec() 1520 spin_unlock_irqrestore(&rocker->cmd_ring_lock, flags); rocker_cmd_exec() 1524 rocker_desc_head_set(rocker, &rocker->cmd_ring, desc_info); rocker_cmd_exec() 1525 spin_unlock_irqrestore(&rocker->cmd_ring_lock, flags); rocker_cmd_exec() 1538 err = process(rocker, rocker_port, desc_info, process_priv); rocker_cmd_exec() 1547 rocker_cmd_get_port_settings_prep(struct rocker *rocker, rocker_cmd_get_port_settings_prep() argument 1568 rocker_cmd_get_port_settings_ethtool_proc(struct rocker *rocker, rocker_cmd_get_port_settings_ethtool_proc() argument 1607 rocker_cmd_get_port_settings_macaddr_proc(struct rocker *rocker, rocker_cmd_get_port_settings_macaddr_proc() argument 1640 rocker_cmd_get_port_settings_phys_name_proc(struct rocker *rocker, rocker_cmd_get_port_settings_phys_name_proc() argument 1682 rocker_cmd_set_port_settings_ethtool_prep(struct rocker *rocker, rocker_cmd_set_port_settings_ethtool_prep() argument 1713 rocker_cmd_set_port_settings_macaddr_prep(struct rocker *rocker, rocker_cmd_set_port_settings_macaddr_prep() argument 1738 rocker_cmd_set_port_learning_prep(struct rocker *rocker, rocker_cmd_set_port_learning_prep() argument 1764 return rocker_cmd_exec(rocker_port->rocker, rocker_port, rocker_cmd_get_port_settings_ethtool() 1773 return rocker_cmd_exec(rocker_port->rocker, rocker_port, rocker_cmd_get_port_settings_macaddr() 1782 return rocker_cmd_exec(rocker_port->rocker, rocker_port, rocker_cmd_set_port_settings_ethtool() 1790 return rocker_cmd_exec(rocker_port->rocker, rocker_port, rocker_cmd_set_port_settings_macaddr() 1797 return rocker_cmd_exec(rocker_port->rocker, rocker_port, rocker_port_set_learning() 1998 static int rocker_cmd_flow_tbl_add(struct rocker *rocker, rocker_cmd_flow_tbl_add() argument 2056 static int rocker_cmd_flow_tbl_del(struct rocker *rocker, rocker_cmd_flow_tbl_del() argument 2166 static int rocker_cmd_group_tbl_add(struct rocker *rocker, rocker_cmd_group_tbl_add() argument 2212 static int rocker_cmd_group_tbl_del(struct rocker *rocker, rocker_cmd_group_tbl_del() argument 2237 static int rocker_init_tbls(struct rocker *rocker) rocker_init_tbls() argument 2239 hash_init(rocker->flow_tbl); rocker_init_tbls() 2240 spin_lock_init(&rocker->flow_tbl_lock); rocker_init_tbls() 2242 hash_init(rocker->group_tbl); rocker_init_tbls() 2243 spin_lock_init(&rocker->group_tbl_lock); rocker_init_tbls() 2245 hash_init(rocker->fdb_tbl); rocker_init_tbls() 2246 spin_lock_init(&rocker->fdb_tbl_lock); rocker_init_tbls() 2248 hash_init(rocker->internal_vlan_tbl); rocker_init_tbls() 2249 spin_lock_init(&rocker->internal_vlan_tbl_lock); rocker_init_tbls() 2251 hash_init(rocker->neigh_tbl); rocker_init_tbls() 2252 spin_lock_init(&rocker->neigh_tbl_lock); rocker_init_tbls() 2257 static void rocker_free_tbls(struct rocker *rocker) rocker_free_tbls() argument 2268 spin_lock_irqsave(&rocker->flow_tbl_lock, flags); rocker_free_tbls() 2269 hash_for_each_safe(rocker->flow_tbl, bkt, tmp, flow_entry, entry) rocker_free_tbls() 2271 spin_unlock_irqrestore(&rocker->flow_tbl_lock, flags); rocker_free_tbls() 2273 spin_lock_irqsave(&rocker->group_tbl_lock, flags); rocker_free_tbls() 2274 hash_for_each_safe(rocker->group_tbl, bkt, tmp, group_entry, entry) rocker_free_tbls() 2276 spin_unlock_irqrestore(&rocker->group_tbl_lock, flags); rocker_free_tbls() 2278 spin_lock_irqsave(&rocker->fdb_tbl_lock, flags); rocker_free_tbls() 2279 hash_for_each_safe(rocker->fdb_tbl, bkt, tmp, fdb_entry, entry) rocker_free_tbls() 2281 spin_unlock_irqrestore(&rocker->fdb_tbl_lock, flags); rocker_free_tbls() 2283 spin_lock_irqsave(&rocker->internal_vlan_tbl_lock, flags); rocker_free_tbls() 2284 hash_for_each_safe(rocker->internal_vlan_tbl, bkt, rocker_free_tbls() 2287 spin_unlock_irqrestore(&rocker->internal_vlan_tbl_lock, flags); rocker_free_tbls() 2289 spin_lock_irqsave(&rocker->neigh_tbl_lock, flags); rocker_free_tbls() 2290 hash_for_each_safe(rocker->neigh_tbl, bkt, tmp, neigh_entry, entry) rocker_free_tbls() 2292 spin_unlock_irqrestore(&rocker->neigh_tbl_lock, flags); rocker_free_tbls() 2296 rocker_flow_tbl_find(struct rocker *rocker, struct rocker_flow_tbl_entry *match) rocker_flow_tbl_find() argument 2301 hash_for_each_possible(rocker->flow_tbl, found, rocker_flow_tbl_find() 2314 struct rocker *rocker = rocker_port->rocker; rocker_flow_tbl_add() local 2321 spin_lock_irqsave(&rocker->flow_tbl_lock, flags); rocker_flow_tbl_add() 2323 found = rocker_flow_tbl_find(rocker, match); rocker_flow_tbl_add() 2333 found->cookie = rocker->flow_tbl_next_cookie++; rocker_flow_tbl_add() 2337 hash_add(rocker->flow_tbl, &found->entry, found->key_crc32); rocker_flow_tbl_add() 2339 spin_unlock_irqrestore(&rocker->flow_tbl_lock, flags); rocker_flow_tbl_add() 2341 return rocker_cmd_exec(rocker, rocker_port, rocker_flow_tbl_add() 2350 struct rocker *rocker = rocker_port->rocker; rocker_flow_tbl_del() local 2358 spin_lock_irqsave(&rocker->flow_tbl_lock, flags); rocker_flow_tbl_del() 2360 found = rocker_flow_tbl_find(rocker, match); rocker_flow_tbl_del() 2367 spin_unlock_irqrestore(&rocker->flow_tbl_lock, flags); rocker_flow_tbl_del() 2372 err = rocker_cmd_exec(rocker, rocker_port, rocker_flow_tbl_del() 2609 rocker_group_tbl_find(struct rocker *rocker, rocker_group_tbl_find() argument 2614 hash_for_each_possible(rocker->group_tbl, found, rocker_group_tbl_find() 2640 struct rocker *rocker = rocker_port->rocker; rocker_group_tbl_add() local 2644 spin_lock_irqsave(&rocker->group_tbl_lock, flags); rocker_group_tbl_add() 2646 found = rocker_group_tbl_find(rocker, match); rocker_group_tbl_add() 2658 hash_add(rocker->group_tbl, &found->entry, found->group_id); rocker_group_tbl_add() 2660 spin_unlock_irqrestore(&rocker->group_tbl_lock, flags); rocker_group_tbl_add() 2662 return rocker_cmd_exec(rocker, rocker_port, rocker_group_tbl_add() 2671 struct rocker *rocker = rocker_port->rocker; rocker_group_tbl_del() local 2676 spin_lock_irqsave(&rocker->group_tbl_lock, flags); rocker_group_tbl_del() 2678 found = rocker_group_tbl_find(rocker, match); rocker_group_tbl_del() 2685 spin_unlock_irqrestore(&rocker->group_tbl_lock, flags); rocker_group_tbl_del() 2690 err = rocker_cmd_exec(rocker, rocker_port, rocker_group_tbl_del() 2784 rocker_neigh_tbl_find(struct rocker *rocker, __be32 ip_addr) rocker_neigh_tbl_find() argument 2788 hash_for_each_possible(rocker->neigh_tbl, found, rocker_neigh_tbl_find() 2796 static void _rocker_neigh_add(struct rocker *rocker, _rocker_neigh_add() argument 2799 entry->index = rocker->neigh_tbl_next_index++; _rocker_neigh_add() 2801 hash_add(rocker->neigh_tbl, &entry->entry, _rocker_neigh_add() 2805 static void _rocker_neigh_del(struct rocker *rocker, _rocker_neigh_del() argument 2814 static void _rocker_neigh_update(struct rocker *rocker, _rocker_neigh_update() argument 2829 struct rocker *rocker = rocker_port->rocker; rocker_port_ipv4_neigh() local 2847 spin_lock_irqsave(&rocker->neigh_tbl_lock, lock_flags); rocker_port_ipv4_neigh() 2849 found = rocker_neigh_tbl_find(rocker, ip_addr); rocker_port_ipv4_neigh() 2860 _rocker_neigh_add(rocker, entry); rocker_port_ipv4_neigh() 2863 _rocker_neigh_del(rocker, found); rocker_port_ipv4_neigh() 2865 _rocker_neigh_update(rocker, found, eth_dst, true); rocker_port_ipv4_neigh() 2871 spin_unlock_irqrestore(&rocker->neigh_tbl_lock, lock_flags); rocker_port_ipv4_neigh() 2947 struct rocker *rocker = rocker_port->rocker; rocker_port_ipv4_nh() local 2961 spin_lock_irqsave(&rocker->neigh_tbl_lock, lock_flags); rocker_port_ipv4_nh() 2963 found = rocker_neigh_tbl_find(rocker, ip_addr); rocker_port_ipv4_nh() 2974 _rocker_neigh_add(rocker, entry); rocker_port_ipv4_nh() 2978 _rocker_neigh_del(rocker, found); rocker_port_ipv4_nh() 2980 _rocker_neigh_update(rocker, found, NULL, false); rocker_port_ipv4_nh() 2986 spin_unlock_irqrestore(&rocker->neigh_tbl_lock, lock_flags); rocker_port_ipv4_nh() 3006 struct rocker *rocker = rocker_port->rocker; rocker_port_vlan_flood_group() local 3013 group_ids = kcalloc(rocker->port_count, sizeof(u32), rocker_port_vlan_flood_group() 3023 for (i = 0; i < rocker->port_count; i++) { rocker_port_vlan_flood_group() 3024 p = rocker->ports[i]; rocker_port_vlan_flood_group() 3053 struct rocker *rocker = rocker_port->rocker; rocker_port_vlan_l2_groups() local 3084 for (i = 0; i < rocker->port_count; i++) { rocker_port_vlan_l2_groups() 3085 p = rocker->ports[i]; rocker_port_vlan_l2_groups() 3446 rocker_fdb_tbl_find(struct rocker *rocker, struct rocker_fdb_tbl_entry *match) rocker_fdb_tbl_find() argument 3450 hash_for_each_possible(rocker->fdb_tbl, found, entry, match->key_crc32) rocker_fdb_tbl_find() 3461 struct rocker *rocker = rocker_port->rocker; rocker_port_fdb() local 3477 spin_lock_irqsave(&rocker->fdb_tbl_lock, lock_flags); rocker_port_fdb() 3479 found = rocker_fdb_tbl_find(rocker, fdb); rocker_port_fdb() 3485 hash_add(rocker->fdb_tbl, &fdb->entry, fdb->key_crc32); rocker_port_fdb() 3488 spin_unlock_irqrestore(&rocker->fdb_tbl_lock, lock_flags); rocker_port_fdb() 3504 struct rocker *rocker = rocker_port->rocker; rocker_port_fdb_flush() local 3516 spin_lock_irqsave(&rocker->fdb_tbl_lock, lock_flags); rocker_port_fdb_flush() 3518 hash_for_each_safe(rocker->fdb_tbl, bkt, tmp, found, entry) { rocker_port_fdb_flush() 3532 spin_unlock_irqrestore(&rocker->fdb_tbl_lock, lock_flags); rocker_port_fdb_flush() 3681 rocker_internal_vlan_tbl_find(struct rocker *rocker, int ifindex) rocker_internal_vlan_tbl_find() argument 3685 hash_for_each_possible(rocker->internal_vlan_tbl, found, rocker_internal_vlan_tbl_find() 3697 struct rocker *rocker = rocker_port->rocker; rocker_port_internal_vlan_id_get() local 3709 spin_lock_irqsave(&rocker->internal_vlan_tbl_lock, lock_flags); rocker_port_internal_vlan_id_get() 3711 found = rocker_internal_vlan_tbl_find(rocker, ifindex); rocker_port_internal_vlan_id_get() 3718 hash_add(rocker->internal_vlan_tbl, &found->entry, found->ifindex); rocker_port_internal_vlan_id_get() 3721 if (test_and_set_bit(i, rocker->internal_vlan_bitmap)) rocker_port_internal_vlan_id_get() 3731 spin_unlock_irqrestore(&rocker->internal_vlan_tbl_lock, lock_flags); rocker_port_internal_vlan_id_get() 3739 struct rocker *rocker = rocker_port->rocker; rocker_port_internal_vlan_id_put() local 3744 spin_lock_irqsave(&rocker->internal_vlan_tbl_lock, lock_flags); rocker_port_internal_vlan_id_put() 3746 found = rocker_internal_vlan_tbl_find(rocker, ifindex); rocker_port_internal_vlan_id_put() 3756 clear_bit(bit, rocker->internal_vlan_bitmap); rocker_port_internal_vlan_id_put() 3762 spin_unlock_irqrestore(&rocker->internal_vlan_tbl_lock, lock_flags); rocker_port_internal_vlan_id_put() 3877 struct rocker *rocker = rocker_port->rocker; rocker_tx_desc_frags_unmap() local 3878 struct pci_dev *pdev = rocker->pdev; rocker_tx_desc_frags_unmap() 3908 struct rocker *rocker = rocker_port->rocker; rocker_tx_desc_frag_map_put() local 3909 struct pci_dev *pdev = rocker->pdev; rocker_tx_desc_frag_map_put() 3941 struct rocker *rocker = rocker_port->rocker; rocker_port_xmit() local 3978 rocker_desc_head_set(rocker, &rocker_port->tx_ring, desc_info); rocker_port_xmit() 4112 struct rocker *rocker = rocker_port->rocker; rocker_port_fdb_dump() local 4121 spin_lock_irqsave(&rocker->fdb_tbl_lock, lock_flags); rocker_port_fdb_dump() 4122 hash_for_each_safe(rocker->fdb_tbl, bkt, tmp, found, entry) { rocker_port_fdb_dump() 4138 spin_unlock_irqrestore(&rocker->fdb_tbl_lock, lock_flags); rocker_port_fdb_dump() 4201 err = rocker_cmd_exec(rocker_port->rocker, rocker_port, rocker_port_get_phys_port_name() 4232 struct rocker *rocker = rocker_port->rocker; rocker_port_swdev_parent_id_get() local 4234 psid->id_len = sizeof(rocker->hw.id); rocker_port_swdev_parent_id_get() 4235 memcpy(&psid->id, &rocker->hw.id, psid->id_len); rocker_port_swdev_parent_id_get() 4339 rocker_cmd_get_port_stats_prep(struct rocker *rocker, rocker_cmd_get_port_stats_prep() argument 4364 rocker_cmd_get_port_stats_ethtool_proc(struct rocker *rocker, rocker_cmd_get_port_stats_ethtool_proc() argument 4405 return rocker_cmd_exec(rocker_port->rocker, rocker_port, rocker_cmd_get_port_stats_ethtool() 4458 struct rocker *rocker = rocker_port->rocker; rocker_port_poll_tx() local 4488 rocker_dma_ring_credits_set(rocker, &rocker_port->tx_ring, credits); rocker_port_poll_tx() 4493 static int rocker_port_rx_proc(struct rocker *rocker, rocker_port_rx_proc() argument 4508 rocker_dma_rx_ring_skb_unmap(rocker, attrs); rocker_port_rx_proc() 4519 return rocker_dma_rx_ring_skb_alloc(rocker, rocker_port, desc_info); rocker_port_rx_proc() 4530 struct rocker *rocker = rocker_port->rocker; rocker_port_poll_rx() local 4544 err = rocker_port_rx_proc(rocker, rocker_port, rocker_port_poll_rx() 4554 rocker_desc_head_set(rocker, &rocker_port->rx_ring, desc_info); rocker_port_poll_rx() 4561 rocker_dma_ring_credits_set(rocker, &rocker_port->rx_ring, credits); rocker_port_poll_rx() 4572 struct rocker *rocker = rocker_port->rocker; rocker_carrier_init() local 4573 u64 link_status = rocker_read64(rocker, PORT_PHYS_LINK_STATUS); rocker_carrier_init() 4583 static void rocker_remove_ports(struct rocker *rocker) rocker_remove_ports() argument 4588 for (i = 0; i < rocker->port_count; i++) { rocker_remove_ports() 4589 rocker_port = rocker->ports[i]; rocker_remove_ports() 4594 kfree(rocker->ports); rocker_remove_ports() 4597 static void rocker_port_dev_addr_init(struct rocker *rocker, rocker_port_dev_addr_init() argument 4600 struct pci_dev *pdev = rocker->pdev; rocker_port_dev_addr_init() 4611 static int rocker_probe_port(struct rocker *rocker, unsigned int port_number) rocker_probe_port() argument 4613 struct pci_dev *pdev = rocker->pdev; rocker_probe_port() 4623 rocker_port->rocker = rocker; rocker_probe_port() 4628 rocker_port_dev_addr_init(rocker, rocker_port); rocker_probe_port() 4647 rocker->ports[port_number] = rocker_port; rocker_probe_port() 4668 static int rocker_probe_ports(struct rocker *rocker) rocker_probe_ports() argument 4674 alloc_size = sizeof(struct rocker_port *) * rocker->port_count; rocker_probe_ports() 4675 rocker->ports = kmalloc(alloc_size, GFP_KERNEL); rocker_probe_ports() 4676 if (!rocker->ports) rocker_probe_ports() 4678 for (i = 0; i < rocker->port_count; i++) { rocker_probe_ports() 4679 err = rocker_probe_port(rocker, i); rocker_probe_ports() 4686 rocker_remove_ports(rocker); rocker_probe_ports() 4690 static int rocker_msix_init(struct rocker *rocker) rocker_msix_init() argument 4692 struct pci_dev *pdev = rocker->pdev; rocker_msix_init() 4701 if (msix_entries != ROCKER_MSIX_VEC_COUNT(rocker->port_count)) rocker_msix_init() 4704 rocker->msix_entries = kmalloc_array(msix_entries, rocker_msix_init() 4707 if (!rocker->msix_entries) rocker_msix_init() 4711 rocker->msix_entries[i].entry = i; rocker_msix_init() 4713 err = pci_enable_msix_exact(pdev, rocker->msix_entries, msix_entries); rocker_msix_init() 4720 kfree(rocker->msix_entries); rocker_msix_init() 4724 static void rocker_msix_fini(struct rocker *rocker) rocker_msix_fini() argument 4726 pci_disable_msix(rocker->pdev); rocker_msix_fini() 4727 kfree(rocker->msix_entries); rocker_msix_fini() 4732 struct rocker *rocker; rocker_probe() local 4735 rocker = kzalloc(sizeof(*rocker), GFP_KERNEL); rocker_probe() 4736 if (!rocker) rocker_probe() 4772 rocker->hw_addr = ioremap(pci_resource_start(pdev, 0), rocker_probe() 4774 if (!rocker->hw_addr) { rocker_probe() 4781 rocker->pdev = pdev; rocker_probe() 4782 pci_set_drvdata(pdev, rocker); rocker_probe() 4784 rocker->port_count = rocker_read32(rocker, PORT_PHYS_COUNT); rocker_probe() 4786 err = rocker_msix_init(rocker); rocker_probe() 4792 err = rocker_basic_hw_test(rocker); rocker_probe() 4798 rocker_write32(rocker, CONTROL, ROCKER_CONTROL_RESET); rocker_probe() 4800 err = rocker_dma_rings_init(rocker); rocker_probe() 4804 err = request_irq(rocker_msix_vector(rocker, ROCKER_MSIX_VEC_CMD), rocker_probe() 4806 rocker_driver_name, rocker); rocker_probe() 4812 err = request_irq(rocker_msix_vector(rocker, ROCKER_MSIX_VEC_EVENT), rocker_probe() 4814 rocker_driver_name, rocker); rocker_probe() 4820 rocker->hw.id = rocker_read64(rocker, SWITCH_ID); rocker_probe() 4822 err = rocker_init_tbls(rocker); rocker_probe() 4824 dev_err(&pdev->dev, "cannot init rocker tables\n"); rocker_probe() 4828 err = rocker_probe_ports(rocker); rocker_probe() 4834 dev_info(&pdev->dev, "Rocker switch with id %016llx\n", rocker->hw.id); rocker_probe() 4839 rocker_free_tbls(rocker); rocker_probe() 4841 free_irq(rocker_msix_vector(rocker, ROCKER_MSIX_VEC_EVENT), rocker); rocker_probe() local 4843 free_irq(rocker_msix_vector(rocker, ROCKER_MSIX_VEC_CMD), rocker); rocker_probe() local 4845 rocker_dma_rings_fini(rocker); rocker_probe() 4848 rocker_msix_fini(rocker); rocker_probe() 4850 iounmap(rocker->hw_addr); rocker_probe() 4858 kfree(rocker); rocker_probe() 4864 struct rocker *rocker = pci_get_drvdata(pdev); rocker_remove() local 4866 rocker_free_tbls(rocker); rocker_remove() 4867 rocker_write32(rocker, CONTROL, ROCKER_CONTROL_RESET); rocker_remove() 4868 rocker_remove_ports(rocker); rocker_remove() 4869 free_irq(rocker_msix_vector(rocker, ROCKER_MSIX_VEC_EVENT), rocker); rocker_remove() local 4870 free_irq(rocker_msix_vector(rocker, ROCKER_MSIX_VEC_CMD), rocker); rocker_remove() local 4871 rocker_dma_rings_fini(rocker); rocker_remove() 4872 rocker_msix_fini(rocker); rocker_remove() 4873 iounmap(rocker->hw_addr); rocker_remove() 4874 pci_release_regions(rocker->pdev); rocker_remove() 4875 pci_disable_device(rocker->pdev); rocker_remove() 4876 kfree(rocker); rocker_remove()
|