Lines Matching full:adapter

100 static int reset_sub_crq_queues(struct ibmvnic_adapter *adapter);
101 static inline void reinit_init_done(struct ibmvnic_adapter *adapter);
102 static void send_query_map(struct ibmvnic_adapter *adapter);
105 static int send_login(struct ibmvnic_adapter *adapter);
106 static void send_query_cap(struct ibmvnic_adapter *adapter);
108 static int init_sub_crq_irqs(struct ibmvnic_adapter *adapter);
112 static int init_crq_queue(struct ibmvnic_adapter *adapter);
113 static int send_query_phys_parms(struct ibmvnic_adapter *adapter);
114 static void ibmvnic_tx_scrq_clean_buffer(struct ibmvnic_adapter *adapter,
116 static void free_long_term_buff(struct ibmvnic_adapter *adapter,
118 static void ibmvnic_disable_irqs(struct ibmvnic_adapter *adapter);
119 static void flush_reset_queue(struct ibmvnic_adapter *adapter);
155 static int send_crq_init_complete(struct ibmvnic_adapter *adapter) in send_crq_init_complete() argument
163 return ibmvnic_send_crq(adapter, &crq); in send_crq_init_complete()
166 static int send_version_xchg(struct ibmvnic_adapter *adapter) in send_version_xchg() argument
175 return ibmvnic_send_crq(adapter, &crq); in send_version_xchg()
178 static void ibmvnic_clean_queue_affinity(struct ibmvnic_adapter *adapter, in ibmvnic_clean_queue_affinity() argument
187 netdev_warn(adapter->netdev, in ibmvnic_clean_queue_affinity()
192 static void ibmvnic_clean_affinity(struct ibmvnic_adapter *adapter) in ibmvnic_clean_affinity() argument
199 rxqs = adapter->rx_scrq; in ibmvnic_clean_affinity()
200 txqs = adapter->tx_scrq; in ibmvnic_clean_affinity()
201 num_txqs = adapter->num_active_tx_scrqs; in ibmvnic_clean_affinity()
202 num_rxqs = adapter->num_active_rx_scrqs; in ibmvnic_clean_affinity()
204 netdev_dbg(adapter->netdev, "%s: Cleaning irq affinity hints", __func__); in ibmvnic_clean_affinity()
207 ibmvnic_clean_queue_affinity(adapter, txqs[i]); in ibmvnic_clean_affinity()
211 ibmvnic_clean_queue_affinity(adapter, rxqs[i]); in ibmvnic_clean_affinity()
250 static void ibmvnic_set_affinity(struct ibmvnic_adapter *adapter) in ibmvnic_set_affinity() argument
252 struct ibmvnic_sub_crq_queue **rxqs = adapter->rx_scrq; in ibmvnic_set_affinity()
253 struct ibmvnic_sub_crq_queue **txqs = adapter->tx_scrq; in ibmvnic_set_affinity()
255 int num_rxqs = adapter->num_active_rx_scrqs, i_rxqs = 0; in ibmvnic_set_affinity()
256 int num_txqs = adapter->num_active_tx_scrqs, i_txqs = 0; in ibmvnic_set_affinity()
262 netdev_dbg(adapter->netdev, "%s: Setting irq affinity hints", __func__); in ibmvnic_set_affinity()
263 if (!(adapter->rx_scrq && adapter->tx_scrq)) { in ibmvnic_set_affinity()
264 netdev_warn(adapter->netdev, in ibmvnic_set_affinity()
299 rc = __netif_set_xps_queue(adapter->netdev, in ibmvnic_set_affinity()
303 netdev_warn(adapter->netdev, "%s: Set XPS on queue %d failed, rc = %d.\n", in ibmvnic_set_affinity()
309 netdev_warn(adapter->netdev, in ibmvnic_set_affinity()
312 ibmvnic_clean_affinity(adapter); in ibmvnic_set_affinity()
318 struct ibmvnic_adapter *adapter; in ibmvnic_cpu_online() local
320 adapter = hlist_entry_safe(node, struct ibmvnic_adapter, node); in ibmvnic_cpu_online()
321 ibmvnic_set_affinity(adapter); in ibmvnic_cpu_online()
327 struct ibmvnic_adapter *adapter; in ibmvnic_cpu_dead() local
329 adapter = hlist_entry_safe(node, struct ibmvnic_adapter, node_dead); in ibmvnic_cpu_dead()
330 ibmvnic_set_affinity(adapter); in ibmvnic_cpu_dead()
336 struct ibmvnic_adapter *adapter; in ibmvnic_cpu_down_prep() local
338 adapter = hlist_entry_safe(node, struct ibmvnic_adapter, node); in ibmvnic_cpu_down_prep()
339 ibmvnic_clean_affinity(adapter); in ibmvnic_cpu_down_prep()
345 static int ibmvnic_cpu_notif_add(struct ibmvnic_adapter *adapter) in ibmvnic_cpu_notif_add() argument
349 ret = cpuhp_state_add_instance_nocalls(ibmvnic_online, &adapter->node); in ibmvnic_cpu_notif_add()
353 &adapter->node_dead); in ibmvnic_cpu_notif_add()
356 cpuhp_state_remove_instance_nocalls(ibmvnic_online, &adapter->node); in ibmvnic_cpu_notif_add()
360 static void ibmvnic_cpu_notif_remove(struct ibmvnic_adapter *adapter) in ibmvnic_cpu_notif_remove() argument
362 cpuhp_state_remove_instance_nocalls(ibmvnic_online, &adapter->node); in ibmvnic_cpu_notif_remove()
364 &adapter->node_dead); in ibmvnic_cpu_notif_remove()
383 * @adapter: private device data
390 static int ibmvnic_wait_for_completion(struct ibmvnic_adapter *adapter, in ibmvnic_wait_for_completion() argument
398 netdev = adapter->netdev; in ibmvnic_wait_for_completion()
402 if (!adapter->crq.active) { in ibmvnic_wait_for_completion()
432 * @adapter: ibmvnic adapter associated to the LTB
445 * with the VIOS and reuse it on next open. Free LTB when adapter is closed.
450 static int alloc_long_term_buff(struct ibmvnic_adapter *adapter, in alloc_long_term_buff() argument
453 struct device *dev = &adapter->vdev->dev; in alloc_long_term_buff()
462 free_long_term_buff(adapter, ltb); in alloc_long_term_buff()
477 ltb->map_id = find_first_zero_bit(adapter->map_ids, in alloc_long_term_buff()
479 bitmap_set(adapter->map_ids, ltb->map_id, 1); in alloc_long_term_buff()
489 mutex_lock(&adapter->fw_lock); in alloc_long_term_buff()
490 adapter->fw_done_rc = 0; in alloc_long_term_buff()
491 reinit_completion(&adapter->fw_done); in alloc_long_term_buff()
493 rc = send_request_map(adapter, ltb->addr, ltb->size, ltb->map_id); in alloc_long_term_buff()
499 rc = ibmvnic_wait_for_completion(adapter, &adapter->fw_done, 10000); in alloc_long_term_buff()
506 if (adapter->fw_done_rc) { in alloc_long_term_buff()
508 adapter->fw_done_rc); in alloc_long_term_buff()
515 mutex_unlock(&adapter->fw_lock); in alloc_long_term_buff()
519 static void free_long_term_buff(struct ibmvnic_adapter *adapter, in free_long_term_buff() argument
522 struct device *dev = &adapter->vdev->dev; in free_long_term_buff()
531 if (adapter->reset_reason != VNIC_RESET_FAILOVER && in free_long_term_buff()
532 adapter->reset_reason != VNIC_RESET_MOBILITY && in free_long_term_buff()
533 adapter->reset_reason != VNIC_RESET_TIMEOUT) in free_long_term_buff()
534 send_request_unmap(adapter, ltb->map_id); in free_long_term_buff()
540 bitmap_clear(adapter->map_ids, ltb->map_id, 1); in free_long_term_buff()
546 * @adapter: The ibmvnic adapter containing this ltb set
552 static void free_ltb_set(struct ibmvnic_adapter *adapter, in free_ltb_set() argument
558 free_long_term_buff(adapter, &ltb_set->ltbs[i]); in free_ltb_set()
568 * @adapter: ibmvnic adapter associated to the LTB
582 static int alloc_ltb_set(struct ibmvnic_adapter *adapter, in alloc_ltb_set() argument
586 struct device *dev = &adapter->vdev->dev; in alloc_ltb_set()
625 free_long_term_buff(adapter, &old_set.ltbs[i]); in alloc_ltb_set()
662 rc = alloc_long_term_buff(adapter, &new_set.ltbs[i], ltb_size); in alloc_ltb_set()
746 static void deactivate_rx_pools(struct ibmvnic_adapter *adapter) in deactivate_rx_pools() argument
750 for (i = 0; i < adapter->num_active_rx_pools; i++) in deactivate_rx_pools()
751 adapter->rx_pool[i].active = 0; in deactivate_rx_pools()
754 static void replenish_rx_pool(struct ibmvnic_adapter *adapter, in replenish_rx_pool() argument
758 u64 handle = adapter->rx_scrq[pool->index]->handle; in replenish_rx_pool()
759 struct device *dev = &adapter->vdev->dev; in replenish_rx_pool()
777 rx_scrq = adapter->rx_scrq[pool->index]; in replenish_rx_pool()
796 skb = netdev_alloc_skb(adapter->netdev, in replenish_rx_pool()
800 adapter->replenish_no_mem++; in replenish_rx_pool()
844 send_subcrq_indirect(adapter, handle, in replenish_rx_pool()
850 adapter->replenish_add_buff_success += ind_bufp->index; in replenish_rx_pool()
873 adapter->replenish_add_buff_failure += ind_bufp->index; in replenish_rx_pool()
876 if (lpar_rc == H_CLOSED || adapter->failover_pending) { in replenish_rx_pool()
882 deactivate_rx_pools(adapter); in replenish_rx_pool()
883 netif_carrier_off(adapter->netdev); in replenish_rx_pool()
887 static void replenish_pools(struct ibmvnic_adapter *adapter) in replenish_pools() argument
891 adapter->replenish_task_cycles++; in replenish_pools()
892 for (i = 0; i < adapter->num_active_rx_pools; i++) { in replenish_pools()
893 if (adapter->rx_pool[i].active) in replenish_pools()
894 replenish_rx_pool(adapter, &adapter->rx_pool[i]); in replenish_pools()
897 netdev_dbg(adapter->netdev, "Replenished %d pools\n", i); in replenish_pools()
900 static void release_stats_buffers(struct ibmvnic_adapter *adapter) in release_stats_buffers() argument
902 kfree(adapter->tx_stats_buffers); in release_stats_buffers()
903 kfree(adapter->rx_stats_buffers); in release_stats_buffers()
904 adapter->tx_stats_buffers = NULL; in release_stats_buffers()
905 adapter->rx_stats_buffers = NULL; in release_stats_buffers()
908 static int init_stats_buffers(struct ibmvnic_adapter *adapter) in init_stats_buffers() argument
910 adapter->tx_stats_buffers = in init_stats_buffers()
914 if (!adapter->tx_stats_buffers) in init_stats_buffers()
917 adapter->rx_stats_buffers = in init_stats_buffers()
921 if (!adapter->rx_stats_buffers) in init_stats_buffers()
927 static void release_stats_token(struct ibmvnic_adapter *adapter) in release_stats_token() argument
929 struct device *dev = &adapter->vdev->dev; in release_stats_token()
931 if (!adapter->stats_token) in release_stats_token()
934 dma_unmap_single(dev, adapter->stats_token, in release_stats_token()
937 adapter->stats_token = 0; in release_stats_token()
940 static int init_stats_token(struct ibmvnic_adapter *adapter) in init_stats_token() argument
942 struct device *dev = &adapter->vdev->dev; in init_stats_token()
946 stok = dma_map_single(dev, &adapter->stats, in init_stats_token()
955 adapter->stats_token = stok; in init_stats_token()
956 netdev_dbg(adapter->netdev, "Stats token initialized (%llx)\n", stok); in init_stats_token()
961 * release_rx_pools() - Release any rx pools attached to @adapter.
962 * @adapter: ibmvnic adapter
966 static void release_rx_pools(struct ibmvnic_adapter *adapter) in release_rx_pools() argument
971 if (!adapter->rx_pool) in release_rx_pools()
974 for (i = 0; i < adapter->num_active_rx_pools; i++) { in release_rx_pools()
975 rx_pool = &adapter->rx_pool[i]; in release_rx_pools()
977 netdev_dbg(adapter->netdev, "Releasing rx_pool[%d]\n", i); in release_rx_pools()
981 free_ltb_set(adapter, &rx_pool->ltb_set); in release_rx_pools()
996 kfree(adapter->rx_pool); in release_rx_pools()
997 adapter->rx_pool = NULL; in release_rx_pools()
998 adapter->num_active_rx_pools = 0; in release_rx_pools()
999 adapter->prev_rx_pool_size = 0; in release_rx_pools()
1004 * @adapter: ibmvnic adapter
1006 * Check if the existing rx pools in the adapter can be reused. The
1016 static bool reuse_rx_pools(struct ibmvnic_adapter *adapter) in reuse_rx_pools() argument
1022 if (!adapter->rx_pool) in reuse_rx_pools()
1025 old_num_pools = adapter->num_active_rx_pools; in reuse_rx_pools()
1026 new_num_pools = adapter->req_rx_queues; in reuse_rx_pools()
1028 old_pool_size = adapter->prev_rx_pool_size; in reuse_rx_pools()
1029 new_pool_size = adapter->req_rx_add_entries_per_subcrq; in reuse_rx_pools()
1031 old_buff_size = adapter->prev_rx_buf_sz; in reuse_rx_pools()
1032 new_buff_size = adapter->cur_rx_buf_sz; in reuse_rx_pools()
1043 * init_rx_pools(): Initialize the set of receiver pools in the adapter.
1046 * Initialize the set of receiver pools in the ibmvnic adapter associated
1055 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in init_rx_pools() local
1056 struct device *dev = &adapter->vdev->dev; in init_rx_pools()
1063 pool_size = adapter->req_rx_add_entries_per_subcrq; in init_rx_pools()
1064 num_pools = adapter->req_rx_queues; in init_rx_pools()
1065 buff_size = adapter->cur_rx_buf_sz; in init_rx_pools()
1067 if (reuse_rx_pools(adapter)) { in init_rx_pools()
1073 release_rx_pools(adapter); in init_rx_pools()
1075 adapter->rx_pool = kcalloc(num_pools, in init_rx_pools()
1078 if (!adapter->rx_pool) { in init_rx_pools()
1086 adapter->num_active_rx_pools = num_pools; in init_rx_pools()
1089 rx_pool = &adapter->rx_pool[i]; in init_rx_pools()
1091 netdev_dbg(adapter->netdev, in init_rx_pools()
1117 adapter->prev_rx_pool_size = pool_size; in init_rx_pools()
1118 adapter->prev_rx_buf_sz = adapter->cur_rx_buf_sz; in init_rx_pools()
1122 rx_pool = &adapter->rx_pool[i]; in init_rx_pools()
1126 rc = alloc_ltb_set(adapter, &rx_pool->ltb_set, in init_rx_pools()
1160 release_rx_pools(adapter); in init_rx_pools()
1168 static void release_vpd_data(struct ibmvnic_adapter *adapter) in release_vpd_data() argument
1170 if (!adapter->vpd) in release_vpd_data()
1173 kfree(adapter->vpd->buff); in release_vpd_data()
1174 kfree(adapter->vpd); in release_vpd_data()
1176 adapter->vpd = NULL; in release_vpd_data()
1179 static void release_one_tx_pool(struct ibmvnic_adapter *adapter, in release_one_tx_pool() argument
1184 free_ltb_set(adapter, &tx_pool->ltb_set); in release_one_tx_pool()
1188 * release_tx_pools() - Release any tx pools attached to @adapter.
1189 * @adapter: ibmvnic adapter
1193 static void release_tx_pools(struct ibmvnic_adapter *adapter) in release_tx_pools() argument
1200 if (!adapter->tx_pool) in release_tx_pools()
1203 for (i = 0; i < adapter->num_active_tx_pools; i++) { in release_tx_pools()
1204 release_one_tx_pool(adapter, &adapter->tx_pool[i]); in release_tx_pools()
1205 release_one_tx_pool(adapter, &adapter->tso_pool[i]); in release_tx_pools()
1208 kfree(adapter->tx_pool); in release_tx_pools()
1209 adapter->tx_pool = NULL; in release_tx_pools()
1210 kfree(adapter->tso_pool); in release_tx_pools()
1211 adapter->tso_pool = NULL; in release_tx_pools()
1212 adapter->num_active_tx_pools = 0; in release_tx_pools()
1213 adapter->prev_tx_pool_size = 0; in release_tx_pools()
1248 * @adapter: ibmvnic adapter
1250 * Check if the existing tx pools in the adapter can be reused. The
1259 static bool reuse_tx_pools(struct ibmvnic_adapter *adapter) in reuse_tx_pools() argument
1265 if (!adapter->tx_pool) in reuse_tx_pools()
1268 old_num_pools = adapter->num_active_tx_pools; in reuse_tx_pools()
1269 new_num_pools = adapter->num_active_tx_scrqs; in reuse_tx_pools()
1270 old_pool_size = adapter->prev_tx_pool_size; in reuse_tx_pools()
1271 new_pool_size = adapter->req_tx_entries_per_subcrq; in reuse_tx_pools()
1272 old_mtu = adapter->prev_mtu; in reuse_tx_pools()
1273 new_mtu = adapter->req_mtu; in reuse_tx_pools()
1284 * init_tx_pools(): Initialize the set of transmit pools in the adapter.
1287 * Initialize the set of transmit pools in the ibmvnic adapter associated
1296 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in init_tx_pools() local
1297 struct device *dev = &adapter->vdev->dev; in init_tx_pools()
1303 num_pools = adapter->req_tx_queues; in init_tx_pools()
1309 if (reuse_tx_pools(adapter)) { in init_tx_pools()
1315 release_tx_pools(adapter); in init_tx_pools()
1317 pool_size = adapter->req_tx_entries_per_subcrq; in init_tx_pools()
1318 num_pools = adapter->num_active_tx_scrqs; in init_tx_pools()
1320 adapter->tx_pool = kcalloc(num_pools, in init_tx_pools()
1322 if (!adapter->tx_pool) in init_tx_pools()
1325 adapter->tso_pool = kcalloc(num_pools, in init_tx_pools()
1330 if (!adapter->tso_pool) { in init_tx_pools()
1331 kfree(adapter->tx_pool); in init_tx_pools()
1332 adapter->tx_pool = NULL; in init_tx_pools()
1339 adapter->num_active_tx_pools = num_pools; in init_tx_pools()
1341 buff_size = adapter->req_mtu + VLAN_HLEN; in init_tx_pools()
1346 i, adapter->req_tx_entries_per_subcrq, buff_size); in init_tx_pools()
1348 rc = init_one_tx_pool(netdev, &adapter->tx_pool[i], in init_tx_pools()
1353 rc = init_one_tx_pool(netdev, &adapter->tso_pool[i], in init_tx_pools()
1360 adapter->prev_tx_pool_size = pool_size; in init_tx_pools()
1361 adapter->prev_mtu = adapter->req_mtu; in init_tx_pools()
1375 tx_pool = &adapter->tx_pool[i]; in init_tx_pools()
1380 rc = alloc_ltb_set(adapter, &tx_pool->ltb_set, in init_tx_pools()
1391 tso_pool = &adapter->tso_pool[i]; in init_tx_pools()
1396 rc = alloc_ltb_set(adapter, &tso_pool->ltb_set, in init_tx_pools()
1410 release_tx_pools(adapter); in init_tx_pools()
1418 static void ibmvnic_napi_enable(struct ibmvnic_adapter *adapter) in ibmvnic_napi_enable() argument
1422 if (adapter->napi_enabled) in ibmvnic_napi_enable()
1425 for (i = 0; i < adapter->req_rx_queues; i++) in ibmvnic_napi_enable()
1426 napi_enable(&adapter->napi[i]); in ibmvnic_napi_enable()
1428 adapter->napi_enabled = true; in ibmvnic_napi_enable()
1431 static void ibmvnic_napi_disable(struct ibmvnic_adapter *adapter) in ibmvnic_napi_disable() argument
1435 if (!adapter->napi_enabled) in ibmvnic_napi_disable()
1438 for (i = 0; i < adapter->req_rx_queues; i++) { in ibmvnic_napi_disable()
1439 netdev_dbg(adapter->netdev, "Disabling napi[%d]\n", i); in ibmvnic_napi_disable()
1440 napi_disable(&adapter->napi[i]); in ibmvnic_napi_disable()
1443 adapter->napi_enabled = false; in ibmvnic_napi_disable()
1446 static int init_napi(struct ibmvnic_adapter *adapter) in init_napi() argument
1450 adapter->napi = kcalloc(adapter->req_rx_queues, in init_napi()
1452 if (!adapter->napi) in init_napi()
1455 for (i = 0; i < adapter->req_rx_queues; i++) { in init_napi()
1456 netdev_dbg(adapter->netdev, "Adding napi[%d]\n", i); in init_napi()
1457 netif_napi_add(adapter->netdev, &adapter->napi[i], in init_napi()
1461 adapter->num_active_rx_napi = adapter->req_rx_queues; in init_napi()
1465 static void release_napi(struct ibmvnic_adapter *adapter) in release_napi() argument
1469 if (!adapter->napi) in release_napi()
1472 for (i = 0; i < adapter->num_active_rx_napi; i++) { in release_napi()
1473 netdev_dbg(adapter->netdev, "Releasing napi[%d]\n", i); in release_napi()
1474 netif_napi_del(&adapter->napi[i]); in release_napi()
1477 kfree(adapter->napi); in release_napi()
1478 adapter->napi = NULL; in release_napi()
1479 adapter->num_active_rx_napi = 0; in release_napi()
1480 adapter->napi_enabled = false; in release_napi()
1511 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_login() local
1524 adapter->init_done_rc = 0; in ibmvnic_login()
1525 reinit_completion(&adapter->init_done); in ibmvnic_login()
1526 rc = send_login(adapter); in ibmvnic_login()
1530 if (!wait_for_completion_timeout(&adapter->init_done, in ibmvnic_login()
1533 adapter->login_pending = false; in ibmvnic_login()
1537 if (adapter->init_done_rc == ABORTED) { in ibmvnic_login()
1540 adapter->init_done_rc = 0; in ibmvnic_login()
1546 } else if (adapter->init_done_rc == PARTIALSUCCESS) { in ibmvnic_login()
1548 release_sub_crqs(adapter, 1); in ibmvnic_login()
1553 adapter->init_done_rc = 0; in ibmvnic_login()
1554 reinit_completion(&adapter->init_done); in ibmvnic_login()
1555 send_query_cap(adapter); in ibmvnic_login()
1556 if (!wait_for_completion_timeout(&adapter->init_done, in ibmvnic_login()
1563 rc = init_sub_crqs(adapter); in ibmvnic_login()
1570 rc = init_sub_crq_irqs(adapter); in ibmvnic_login()
1577 } else if (adapter->init_done_rc) { in ibmvnic_login()
1578 netdev_warn(netdev, "Adapter login failed, init_done_rc = %d\n", in ibmvnic_login()
1579 adapter->init_done_rc); in ibmvnic_login()
1582 /* adapter login failed, so free any CRQs or sub-CRQs in ibmvnic_login()
1591 adapter->init_done_rc = 0; in ibmvnic_login()
1592 release_sub_crqs(adapter, true); in ibmvnic_login()
1600 reinit_init_done(adapter); in ibmvnic_login()
1604 adapter->failover_pending = false; in ibmvnic_login()
1605 release_crq_queue(adapter); in ibmvnic_login()
1616 spin_lock_irqsave(&adapter->rwi_lock, flags); in ibmvnic_login()
1617 flush_reset_queue(adapter); in ibmvnic_login()
1618 spin_unlock_irqrestore(&adapter->rwi_lock, in ibmvnic_login()
1621 rc = init_crq_queue(adapter); in ibmvnic_login()
1628 rc = ibmvnic_reset_init(adapter, false); in ibmvnic_login()
1642 __ibmvnic_set_mac(netdev, adapter->mac_addr); in ibmvnic_login()
1644 netdev_dbg(netdev, "[S:%s] Login succeeded\n", adapter_state_to_string(adapter->state)); in ibmvnic_login()
1648 static void release_login_buffer(struct ibmvnic_adapter *adapter) in release_login_buffer() argument
1650 if (!adapter->login_buf) in release_login_buffer()
1653 dma_unmap_single(&adapter->vdev->dev, adapter->login_buf_token, in release_login_buffer()
1654 adapter->login_buf_sz, DMA_TO_DEVICE); in release_login_buffer()
1655 kfree(adapter->login_buf); in release_login_buffer()
1656 adapter->login_buf = NULL; in release_login_buffer()
1659 static void release_login_rsp_buffer(struct ibmvnic_adapter *adapter) in release_login_rsp_buffer() argument
1661 if (!adapter->login_rsp_buf) in release_login_rsp_buffer()
1664 dma_unmap_single(&adapter->vdev->dev, adapter->login_rsp_buf_token, in release_login_rsp_buffer()
1665 adapter->login_rsp_buf_sz, DMA_FROM_DEVICE); in release_login_rsp_buffer()
1666 kfree(adapter->login_rsp_buf); in release_login_rsp_buffer()
1667 adapter->login_rsp_buf = NULL; in release_login_rsp_buffer()
1670 static void release_resources(struct ibmvnic_adapter *adapter) in release_resources() argument
1672 release_vpd_data(adapter); in release_resources()
1674 release_napi(adapter); in release_resources()
1675 release_login_buffer(adapter); in release_resources()
1676 release_login_rsp_buffer(adapter); in release_resources()
1679 static int set_link_state(struct ibmvnic_adapter *adapter, u8 link_state) in set_link_state() argument
1681 struct net_device *netdev = adapter->netdev; in set_link_state()
1697 reinit_completion(&adapter->init_done); in set_link_state()
1698 rc = ibmvnic_send_crq(adapter, &crq); in set_link_state()
1704 if (!wait_for_completion_timeout(&adapter->init_done, in set_link_state()
1710 if (adapter->init_done_rc == PARTIALSUCCESS) { in set_link_state()
1714 } else if (adapter->init_done_rc) { in set_link_state()
1716 adapter->init_done_rc); in set_link_state()
1717 return adapter->init_done_rc; in set_link_state()
1726 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in set_real_num_queues() local
1730 adapter->req_tx_queues, adapter->req_rx_queues); in set_real_num_queues()
1732 rc = netif_set_real_num_tx_queues(netdev, adapter->req_tx_queues); in set_real_num_queues()
1738 rc = netif_set_real_num_rx_queues(netdev, adapter->req_rx_queues); in set_real_num_queues()
1745 static int ibmvnic_get_vpd(struct ibmvnic_adapter *adapter) in ibmvnic_get_vpd() argument
1747 struct device *dev = &adapter->vdev->dev; in ibmvnic_get_vpd()
1752 if (adapter->vpd->buff) in ibmvnic_get_vpd()
1753 len = adapter->vpd->len; in ibmvnic_get_vpd()
1755 mutex_lock(&adapter->fw_lock); in ibmvnic_get_vpd()
1756 adapter->fw_done_rc = 0; in ibmvnic_get_vpd()
1757 reinit_completion(&adapter->fw_done); in ibmvnic_get_vpd()
1761 rc = ibmvnic_send_crq(adapter, &crq); in ibmvnic_get_vpd()
1763 mutex_unlock(&adapter->fw_lock); in ibmvnic_get_vpd()
1767 rc = ibmvnic_wait_for_completion(adapter, &adapter->fw_done, 10000); in ibmvnic_get_vpd()
1770 mutex_unlock(&adapter->fw_lock); in ibmvnic_get_vpd()
1773 mutex_unlock(&adapter->fw_lock); in ibmvnic_get_vpd()
1775 if (!adapter->vpd->len) in ibmvnic_get_vpd()
1778 if (!adapter->vpd->buff) in ibmvnic_get_vpd()
1779 adapter->vpd->buff = kzalloc(adapter->vpd->len, GFP_KERNEL); in ibmvnic_get_vpd()
1780 else if (adapter->vpd->len != len) in ibmvnic_get_vpd()
1781 adapter->vpd->buff = in ibmvnic_get_vpd()
1782 krealloc(adapter->vpd->buff, in ibmvnic_get_vpd()
1783 adapter->vpd->len, GFP_KERNEL); in ibmvnic_get_vpd()
1785 if (!adapter->vpd->buff) { in ibmvnic_get_vpd()
1790 adapter->vpd->dma_addr = in ibmvnic_get_vpd()
1791 dma_map_single(dev, adapter->vpd->buff, adapter->vpd->len, in ibmvnic_get_vpd()
1793 if (dma_mapping_error(dev, adapter->vpd->dma_addr)) { in ibmvnic_get_vpd()
1795 kfree(adapter->vpd->buff); in ibmvnic_get_vpd()
1796 adapter->vpd->buff = NULL; in ibmvnic_get_vpd()
1800 mutex_lock(&adapter->fw_lock); in ibmvnic_get_vpd()
1801 adapter->fw_done_rc = 0; in ibmvnic_get_vpd()
1802 reinit_completion(&adapter->fw_done); in ibmvnic_get_vpd()
1806 crq.get_vpd.ioba = cpu_to_be32(adapter->vpd->dma_addr); in ibmvnic_get_vpd()
1807 crq.get_vpd.len = cpu_to_be32((u32)adapter->vpd->len); in ibmvnic_get_vpd()
1808 rc = ibmvnic_send_crq(adapter, &crq); in ibmvnic_get_vpd()
1810 kfree(adapter->vpd->buff); in ibmvnic_get_vpd()
1811 adapter->vpd->buff = NULL; in ibmvnic_get_vpd()
1812 mutex_unlock(&adapter->fw_lock); in ibmvnic_get_vpd()
1816 rc = ibmvnic_wait_for_completion(adapter, &adapter->fw_done, 10000); in ibmvnic_get_vpd()
1819 kfree(adapter->vpd->buff); in ibmvnic_get_vpd()
1820 adapter->vpd->buff = NULL; in ibmvnic_get_vpd()
1821 mutex_unlock(&adapter->fw_lock); in ibmvnic_get_vpd()
1825 mutex_unlock(&adapter->fw_lock); in ibmvnic_get_vpd()
1829 static int init_resources(struct ibmvnic_adapter *adapter) in init_resources() argument
1831 struct net_device *netdev = adapter->netdev; in init_resources()
1838 adapter->vpd = kzalloc(sizeof(*adapter->vpd), GFP_KERNEL); in init_resources()
1839 if (!adapter->vpd) in init_resources()
1843 rc = ibmvnic_get_vpd(adapter); in init_resources()
1849 rc = init_napi(adapter); in init_resources()
1853 send_query_map(adapter); in init_resources()
1865 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in __ibmvnic_open() local
1866 enum vnic_state prev_state = adapter->state; in __ibmvnic_open()
1869 adapter->state = VNIC_OPENING; in __ibmvnic_open()
1870 replenish_pools(adapter); in __ibmvnic_open()
1871 ibmvnic_napi_enable(adapter); in __ibmvnic_open()
1876 for (i = 0; i < adapter->req_rx_queues; i++) { in __ibmvnic_open()
1879 enable_irq(adapter->rx_scrq[i]->irq); in __ibmvnic_open()
1880 enable_scrq_irq(adapter, adapter->rx_scrq[i]); in __ibmvnic_open()
1883 for (i = 0; i < adapter->req_tx_queues; i++) { in __ibmvnic_open()
1886 enable_irq(adapter->tx_scrq[i]->irq); in __ibmvnic_open()
1887 enable_scrq_irq(adapter, adapter->tx_scrq[i]); in __ibmvnic_open()
1894 if (adapter->reset_reason != VNIC_RESET_NON_FATAL) in __ibmvnic_open()
1898 rc = set_link_state(adapter, IBMVNIC_LOGICAL_LNK_UP); in __ibmvnic_open()
1900 ibmvnic_napi_disable(adapter); in __ibmvnic_open()
1901 ibmvnic_disable_irqs(adapter); in __ibmvnic_open()
1905 adapter->tx_queues_active = true; in __ibmvnic_open()
1917 for (i = 0; i < adapter->req_rx_queues; i++) in __ibmvnic_open()
1918 napi_schedule(&adapter->napi[i]); in __ibmvnic_open()
1921 adapter->state = VNIC_OPEN; in __ibmvnic_open()
1927 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_open() local
1936 * It should be safe to overwrite the adapter->state here. Since in ibmvnic_open()
1943 if (adapter->failover_pending || (test_bit(0, &adapter->resetting))) { in ibmvnic_open()
1945 adapter_state_to_string(adapter->state), in ibmvnic_open()
1946 adapter->failover_pending); in ibmvnic_open()
1947 adapter->state = VNIC_OPEN; in ibmvnic_open()
1952 if (adapter->state != VNIC_CLOSED) { in ibmvnic_open()
1957 rc = init_resources(adapter); in ibmvnic_open()
1972 (adapter->failover_pending || (test_bit(0, &adapter->resetting)))) { in ibmvnic_open()
1973 adapter->state = VNIC_OPEN; in ibmvnic_open()
1978 release_resources(adapter); in ibmvnic_open()
1979 release_rx_pools(adapter); in ibmvnic_open()
1980 release_tx_pools(adapter); in ibmvnic_open()
1986 static void clean_rx_pools(struct ibmvnic_adapter *adapter) in clean_rx_pools() argument
1994 if (!adapter->rx_pool) in clean_rx_pools()
1997 rx_scrqs = adapter->num_active_rx_pools; in clean_rx_pools()
1998 rx_entries = adapter->req_rx_add_entries_per_subcrq; in clean_rx_pools()
2002 rx_pool = &adapter->rx_pool[i]; in clean_rx_pools()
2006 netdev_dbg(adapter->netdev, "Cleaning rx_pool[%d]\n", i); in clean_rx_pools()
2017 static void clean_one_tx_pool(struct ibmvnic_adapter *adapter, in clean_one_tx_pool() argument
2038 static void clean_tx_pools(struct ibmvnic_adapter *adapter) in clean_tx_pools() argument
2043 if (!adapter->tx_pool || !adapter->tso_pool) in clean_tx_pools()
2046 tx_scrqs = adapter->num_active_tx_pools; in clean_tx_pools()
2050 netdev_dbg(adapter->netdev, "Cleaning tx_pool[%d]\n", i); in clean_tx_pools()
2051 clean_one_tx_pool(adapter, &adapter->tx_pool[i]); in clean_tx_pools()
2052 clean_one_tx_pool(adapter, &adapter->tso_pool[i]); in clean_tx_pools()
2056 static void ibmvnic_disable_irqs(struct ibmvnic_adapter *adapter) in ibmvnic_disable_irqs() argument
2058 struct net_device *netdev = adapter->netdev; in ibmvnic_disable_irqs()
2061 if (adapter->tx_scrq) { in ibmvnic_disable_irqs()
2062 for (i = 0; i < adapter->req_tx_queues; i++) in ibmvnic_disable_irqs()
2063 if (adapter->tx_scrq[i]->irq) { in ibmvnic_disable_irqs()
2066 disable_scrq_irq(adapter, adapter->tx_scrq[i]); in ibmvnic_disable_irqs()
2067 disable_irq(adapter->tx_scrq[i]->irq); in ibmvnic_disable_irqs()
2071 if (adapter->rx_scrq) { in ibmvnic_disable_irqs()
2072 for (i = 0; i < adapter->req_rx_queues; i++) { in ibmvnic_disable_irqs()
2073 if (adapter->rx_scrq[i]->irq) { in ibmvnic_disable_irqs()
2076 disable_scrq_irq(adapter, adapter->rx_scrq[i]); in ibmvnic_disable_irqs()
2077 disable_irq(adapter->rx_scrq[i]->irq); in ibmvnic_disable_irqs()
2085 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_cleanup() local
2089 adapter->tx_queues_active = false; in ibmvnic_cleanup()
2096 if (test_bit(0, &adapter->resetting)) in ibmvnic_cleanup()
2101 ibmvnic_napi_disable(adapter); in ibmvnic_cleanup()
2102 ibmvnic_disable_irqs(adapter); in ibmvnic_cleanup()
2107 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in __ibmvnic_close() local
2110 adapter->state = VNIC_CLOSING; in __ibmvnic_close()
2111 rc = set_link_state(adapter, IBMVNIC_LOGICAL_LNK_DN); in __ibmvnic_close()
2112 adapter->state = VNIC_CLOSED; in __ibmvnic_close()
2118 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_close() local
2122 adapter_state_to_string(adapter->state), in ibmvnic_close()
2123 adapter->failover_pending, in ibmvnic_close()
2124 adapter->force_reset_recovery); in ibmvnic_close()
2129 if (adapter->failover_pending) { in ibmvnic_close()
2130 adapter->state = VNIC_CLOSED; in ibmvnic_close()
2136 clean_rx_pools(adapter); in ibmvnic_close()
2137 clean_tx_pools(adapter); in ibmvnic_close()
2294 static void ibmvnic_tx_scrq_clean_buffer(struct ibmvnic_adapter *adapter, in ibmvnic_tx_scrq_clean_buffer() argument
2316 tx_pool = &adapter->tso_pool[queue_num]; in ibmvnic_tx_scrq_clean_buffer()
2319 tx_pool = &adapter->tx_pool[queue_num]; in ibmvnic_tx_scrq_clean_buffer()
2326 adapter->netdev->stats.tx_packets--; in ibmvnic_tx_scrq_clean_buffer()
2327 adapter->netdev->stats.tx_bytes -= tx_buff->skb->len; in ibmvnic_tx_scrq_clean_buffer()
2328 adapter->tx_stats_buffers[queue_num].packets--; in ibmvnic_tx_scrq_clean_buffer()
2329 adapter->tx_stats_buffers[queue_num].bytes -= in ibmvnic_tx_scrq_clean_buffer()
2333 adapter->netdev->stats.tx_dropped++; in ibmvnic_tx_scrq_clean_buffer()
2339 (adapter->req_tx_entries_per_subcrq / 2) && in ibmvnic_tx_scrq_clean_buffer()
2340 __netif_subqueue_stopped(adapter->netdev, queue_num)) { in ibmvnic_tx_scrq_clean_buffer()
2343 if (adapter->tx_queues_active) { in ibmvnic_tx_scrq_clean_buffer()
2344 netif_wake_subqueue(adapter->netdev, queue_num); in ibmvnic_tx_scrq_clean_buffer()
2345 netdev_dbg(adapter->netdev, "Started queue %d\n", in ibmvnic_tx_scrq_clean_buffer()
2353 static int ibmvnic_tx_scrq_flush(struct ibmvnic_adapter *adapter, in ibmvnic_tx_scrq_flush() argument
2369 rc = send_subcrq_indirect(adapter, handle, dma_addr, entries); in ibmvnic_tx_scrq_flush()
2371 ibmvnic_tx_scrq_clean_buffer(adapter, tx_scrq); in ibmvnic_tx_scrq_flush()
2379 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_xmit() local
2381 u8 *hdrs = (u8 *)&adapter->tx_rx_desc_req; in ibmvnic_xmit()
2382 struct device *dev = &adapter->vdev->dev; in ibmvnic_xmit()
2410 if (!adapter->tx_queues_active) { in ibmvnic_xmit()
2419 tx_scrq = adapter->tx_scrq[queue_num]; in ibmvnic_xmit()
2427 ibmvnic_tx_scrq_flush(adapter, tx_scrq); in ibmvnic_xmit()
2432 tx_pool = &adapter->tso_pool[queue_num]; in ibmvnic_xmit()
2434 tx_pool = &adapter->tx_pool[queue_num]; in ibmvnic_xmit()
2442 ibmvnic_tx_scrq_flush(adapter, tx_scrq); in ibmvnic_xmit()
2513 if (adapter->vlan_header_insertion && skb_vlan_tag_present(skb)) { in ibmvnic_xmit()
2548 lpar_rc = ibmvnic_tx_scrq_flush(adapter, tx_scrq); in ibmvnic_xmit()
2560 lpar_rc = ibmvnic_tx_scrq_flush(adapter, tx_scrq); in ibmvnic_xmit()
2566 >= adapter->req_tx_entries_per_subcrq) { in ibmvnic_xmit()
2588 if (lpar_rc == H_CLOSED || adapter->failover_pending) { in ibmvnic_xmit()
2602 adapter->tx_send_failed += tx_send_failed; in ibmvnic_xmit()
2603 adapter->tx_map_failed += tx_map_failed; in ibmvnic_xmit()
2604 adapter->tx_stats_buffers[queue_num].packets += tx_packets; in ibmvnic_xmit()
2605 adapter->tx_stats_buffers[queue_num].bytes += tx_bytes; in ibmvnic_xmit()
2606 adapter->tx_stats_buffers[queue_num].dropped_packets += tx_dropped; in ibmvnic_xmit()
2613 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_set_multi() local
2622 if (!adapter->promisc_supported) in ibmvnic_set_multi()
2631 ibmvnic_send_crq(adapter, &crq); in ibmvnic_set_multi()
2638 ibmvnic_send_crq(adapter, &crq); in ibmvnic_set_multi()
2648 ibmvnic_send_crq(adapter, &crq); in ibmvnic_set_multi()
2656 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in __ibmvnic_set_mac() local
2670 mutex_lock(&adapter->fw_lock); in __ibmvnic_set_mac()
2671 adapter->fw_done_rc = 0; in __ibmvnic_set_mac()
2672 reinit_completion(&adapter->fw_done); in __ibmvnic_set_mac()
2674 rc = ibmvnic_send_crq(adapter, &crq); in __ibmvnic_set_mac()
2677 mutex_unlock(&adapter->fw_lock); in __ibmvnic_set_mac()
2681 rc = ibmvnic_wait_for_completion(adapter, &adapter->fw_done, 10000); in __ibmvnic_set_mac()
2683 if (rc || adapter->fw_done_rc) { in __ibmvnic_set_mac()
2685 mutex_unlock(&adapter->fw_lock); in __ibmvnic_set_mac()
2688 mutex_unlock(&adapter->fw_lock); in __ibmvnic_set_mac()
2691 ether_addr_copy(adapter->mac_addr, netdev->dev_addr); in __ibmvnic_set_mac()
2697 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_set_mac() local
2705 ether_addr_copy(adapter->mac_addr, addr->sa_data); in ibmvnic_set_mac()
2706 if (adapter->state != VNIC_PROBED) in ibmvnic_set_mac()
2740 static inline void reinit_init_done(struct ibmvnic_adapter *adapter) in reinit_init_done() argument
2742 reinit_completion(&adapter->init_done); in reinit_init_done()
2743 adapter->init_done_rc = 0; in reinit_init_done()
2750 static int do_reset(struct ibmvnic_adapter *adapter, in do_reset() argument
2753 struct net_device *netdev = adapter->netdev; in do_reset()
2758 netdev_dbg(adapter->netdev, in do_reset()
2760 adapter_state_to_string(adapter->state), in do_reset()
2761 adapter->failover_pending, in do_reset()
2765 adapter->reset_reason = rwi->reset_reason; in do_reset()
2767 if (!(adapter->reset_reason == VNIC_RESET_CHANGE_PARAM)) in do_reset()
2775 adapter->failover_pending = false; in do_reset()
2778 reset_state = adapter->state; in do_reset()
2787 old_num_rx_queues = adapter->req_rx_queues; in do_reset()
2788 old_num_tx_queues = adapter->req_tx_queues; in do_reset()
2789 old_num_rx_slots = adapter->req_rx_add_entries_per_subcrq; in do_reset()
2790 old_num_tx_slots = adapter->req_tx_entries_per_subcrq; in do_reset()
2795 adapter->reset_reason != VNIC_RESET_MOBILITY && in do_reset()
2796 adapter->reset_reason != VNIC_RESET_FAILOVER) { in do_reset()
2797 if (adapter->reset_reason == VNIC_RESET_CHANGE_PARAM) { in do_reset()
2802 adapter->state = VNIC_CLOSING; in do_reset()
2810 rc = set_link_state(adapter, IBMVNIC_LOGICAL_LNK_DN); in do_reset()
2815 if (adapter->state == VNIC_OPEN) { in do_reset()
2818 * set the adapter state to OPEN. Update our in do_reset()
2826 adapter->state = VNIC_CLOSING; in do_reset()
2829 if (adapter->state != VNIC_CLOSING) { in do_reset()
2830 /* If someone else changed the adapter state in do_reset()
2836 adapter->state = VNIC_CLOSED; in do_reset()
2840 if (adapter->reset_reason == VNIC_RESET_CHANGE_PARAM) { in do_reset()
2841 release_resources(adapter); in do_reset()
2842 release_sub_crqs(adapter, 1); in do_reset()
2843 release_crq_queue(adapter); in do_reset()
2846 if (adapter->reset_reason != VNIC_RESET_NON_FATAL) { in do_reset()
2850 adapter->state = VNIC_PROBED; in do_reset()
2852 reinit_init_done(adapter); in do_reset()
2854 if (adapter->reset_reason == VNIC_RESET_CHANGE_PARAM) { in do_reset()
2855 rc = init_crq_queue(adapter); in do_reset()
2856 } else if (adapter->reset_reason == VNIC_RESET_MOBILITY) { in do_reset()
2857 rc = ibmvnic_reenable_crq_queue(adapter); in do_reset()
2858 release_sub_crqs(adapter, 1); in do_reset()
2860 rc = ibmvnic_reset_crq(adapter); in do_reset()
2862 rc = vio_enable_interrupts(adapter->vdev); in do_reset()
2864 netdev_err(adapter->netdev, in do_reset()
2871 netdev_err(adapter->netdev, in do_reset()
2876 rc = ibmvnic_reset_init(adapter, true); in do_reset()
2880 /* If the adapter was in PROBE or DOWN state prior to the reset, in do_reset()
2892 if (adapter->reset_reason == VNIC_RESET_CHANGE_PARAM) { in do_reset()
2893 rc = init_resources(adapter); in do_reset()
2896 } else if (adapter->req_rx_queues != old_num_rx_queues || in do_reset()
2897 adapter->req_tx_queues != old_num_tx_queues || in do_reset()
2898 adapter->req_rx_add_entries_per_subcrq != in do_reset()
2900 adapter->req_tx_entries_per_subcrq != in do_reset()
2902 !adapter->rx_pool || in do_reset()
2903 !adapter->tso_pool || in do_reset()
2904 !adapter->tx_pool) { in do_reset()
2905 release_napi(adapter); in do_reset()
2906 release_vpd_data(adapter); in do_reset()
2908 rc = init_resources(adapter); in do_reset()
2929 ibmvnic_disable_irqs(adapter); in do_reset()
2931 adapter->state = VNIC_CLOSED; in do_reset()
2947 if (adapter->reset_reason == VNIC_RESET_FAILOVER || in do_reset()
2948 adapter->reset_reason == VNIC_RESET_MOBILITY) in do_reset()
2954 /* restore the adapter state if reset failed */ in do_reset()
2956 adapter->state = reset_state; in do_reset()
2958 if (!(adapter->reset_reason == VNIC_RESET_CHANGE_PARAM)) in do_reset()
2961 netdev_dbg(adapter->netdev, "[S:%s FOP:%d] Reset done, rc %d\n", in do_reset()
2962 adapter_state_to_string(adapter->state), in do_reset()
2963 adapter->failover_pending, rc); in do_reset()
2967 static int do_hard_reset(struct ibmvnic_adapter *adapter, in do_hard_reset() argument
2970 struct net_device *netdev = adapter->netdev; in do_hard_reset()
2973 netdev_dbg(adapter->netdev, "Hard resetting driver (%s)\n", in do_hard_reset()
2977 reset_state = adapter->state; in do_hard_reset()
2985 adapter->reset_reason = rwi->reset_reason; in do_hard_reset()
2988 release_resources(adapter); in do_hard_reset()
2989 release_sub_crqs(adapter, 0); in do_hard_reset()
2990 release_crq_queue(adapter); in do_hard_reset()
2995 adapter->state = VNIC_PROBED; in do_hard_reset()
2997 reinit_init_done(adapter); in do_hard_reset()
2999 rc = init_crq_queue(adapter); in do_hard_reset()
3001 netdev_err(adapter->netdev, in do_hard_reset()
3006 rc = ibmvnic_reset_init(adapter, false); in do_hard_reset()
3010 /* If the adapter was in PROBE or DOWN state prior to the reset, in do_hard_reset()
3020 rc = init_resources(adapter); in do_hard_reset()
3024 ibmvnic_disable_irqs(adapter); in do_hard_reset()
3025 adapter->state = VNIC_CLOSED; in do_hard_reset()
3038 /* restore adapter state if reset failed */ in do_hard_reset()
3040 adapter->state = reset_state; in do_hard_reset()
3041 netdev_dbg(adapter->netdev, "[S:%s FOP:%d] Hard reset done, rc %d\n", in do_hard_reset()
3042 adapter_state_to_string(adapter->state), in do_hard_reset()
3043 adapter->failover_pending, rc); in do_hard_reset()
3047 static struct ibmvnic_rwi *get_next_rwi(struct ibmvnic_adapter *adapter) in get_next_rwi() argument
3052 spin_lock_irqsave(&adapter->rwi_lock, flags); in get_next_rwi()
3054 if (!list_empty(&adapter->rwi_list)) { in get_next_rwi()
3055 rwi = list_first_entry(&adapter->rwi_list, struct ibmvnic_rwi, in get_next_rwi()
3062 spin_unlock_irqrestore(&adapter->rwi_lock, flags); in get_next_rwi()
3068 * @adapter: ibmvnic_adapter struct
3080 static int do_passive_init(struct ibmvnic_adapter *adapter) in do_passive_init() argument
3083 struct net_device *netdev = adapter->netdev; in do_passive_init()
3084 struct device *dev = &adapter->vdev->dev; in do_passive_init()
3089 adapter->state = VNIC_PROBING; in do_passive_init()
3090 reinit_completion(&adapter->init_done); in do_passive_init()
3091 adapter->init_done_rc = 0; in do_passive_init()
3092 adapter->crq.active = true; in do_passive_init()
3094 rc = send_crq_init_complete(adapter); in do_passive_init()
3098 rc = send_version_xchg(adapter); in do_passive_init()
3100 netdev_dbg(adapter->netdev, "send_version_xchg failed, rc=%d\n", rc); in do_passive_init()
3102 if (!wait_for_completion_timeout(&adapter->init_done, timeout)) { in do_passive_init()
3108 rc = init_sub_crqs(adapter); in do_passive_init()
3114 rc = init_sub_crq_irqs(adapter); in do_passive_init()
3120 netdev->mtu = adapter->req_mtu - ETH_HLEN; in do_passive_init()
3121 netdev->min_mtu = adapter->min_mtu - ETH_HLEN; in do_passive_init()
3122 netdev->max_mtu = adapter->max_mtu - ETH_HLEN; in do_passive_init()
3124 adapter->state = VNIC_PROBED; in do_passive_init()
3130 release_sub_crqs(adapter, 1); in do_passive_init()
3132 adapter->state = VNIC_DOWN; in do_passive_init()
3138 struct ibmvnic_adapter *adapter; in __ibmvnic_reset() local
3150 adapter = container_of(work, struct ibmvnic_adapter, ibmvnic_reset); in __ibmvnic_reset()
3151 dev = &adapter->vdev->dev; in __ibmvnic_reset()
3162 if (adapter->state == VNIC_PROBING && in __ibmvnic_reset()
3163 !wait_for_completion_timeout(&adapter->probe_done, timeout)) { in __ibmvnic_reset()
3166 &adapter->ibmvnic_delayed_reset, in __ibmvnic_reset()
3171 /* adapter is done with probe (i.e state is never VNIC_PROBING now) */ in __ibmvnic_reset()
3172 if (adapter->state == VNIC_REMOVING) in __ibmvnic_reset()
3200 spin_lock(&adapter->rwi_lock); in __ibmvnic_reset()
3201 if (!list_empty(&adapter->rwi_list)) { in __ibmvnic_reset()
3202 if (test_and_set_bit_lock(0, &adapter->resetting)) { in __ibmvnic_reset()
3204 &adapter->ibmvnic_delayed_reset, in __ibmvnic_reset()
3210 spin_unlock(&adapter->rwi_lock); in __ibmvnic_reset()
3215 rwi = get_next_rwi(adapter); in __ibmvnic_reset()
3217 spin_lock_irqsave(&adapter->state_lock, flags); in __ibmvnic_reset()
3219 if (adapter->state == VNIC_REMOVING || in __ibmvnic_reset()
3220 adapter->state == VNIC_REMOVED) { in __ibmvnic_reset()
3221 spin_unlock_irqrestore(&adapter->state_lock, flags); in __ibmvnic_reset()
3228 reset_state = adapter->state; in __ibmvnic_reset()
3231 spin_unlock_irqrestore(&adapter->state_lock, flags); in __ibmvnic_reset()
3235 rc = do_passive_init(adapter); in __ibmvnic_reset()
3238 netif_carrier_on(adapter->netdev); in __ibmvnic_reset()
3239 } else if (adapter->force_reset_recovery) { in __ibmvnic_reset()
3244 adapter->failover_pending = false; in __ibmvnic_reset()
3247 if (adapter->wait_for_reset) { in __ibmvnic_reset()
3249 adapter->force_reset_recovery = false; in __ibmvnic_reset()
3250 rc = do_hard_reset(adapter, rwi, reset_state); in __ibmvnic_reset()
3253 adapter->force_reset_recovery = false; in __ibmvnic_reset()
3254 rc = do_hard_reset(adapter, rwi, reset_state); in __ibmvnic_reset()
3267 * adapter some time to settle down before retrying. in __ibmvnic_reset()
3270 netdev_dbg(adapter->netdev, in __ibmvnic_reset()
3272 adapter_state_to_string(adapter->state), in __ibmvnic_reset()
3278 rc = do_reset(adapter, rwi, reset_state); in __ibmvnic_reset()
3281 adapter->last_reset_time = jiffies; in __ibmvnic_reset()
3284 netdev_dbg(adapter->netdev, "Reset failed, rc=%d\n", rc); in __ibmvnic_reset()
3286 rwi = get_next_rwi(adapter); in __ibmvnic_reset()
3290 * the adapter would be in an undefined state. So retry the in __ibmvnic_reset()
3305 adapter->force_reset_recovery = true; in __ibmvnic_reset()
3308 if (adapter->wait_for_reset) { in __ibmvnic_reset()
3309 adapter->reset_done_rc = rc; in __ibmvnic_reset()
3310 complete(&adapter->reset_done); in __ibmvnic_reset()
3313 clear_bit_unlock(0, &adapter->resetting); in __ibmvnic_reset()
3315 netdev_dbg(adapter->netdev, in __ibmvnic_reset()
3317 adapter_state_to_string(adapter->state), in __ibmvnic_reset()
3318 adapter->force_reset_recovery, in __ibmvnic_reset()
3319 adapter->wait_for_reset); in __ibmvnic_reset()
3324 struct ibmvnic_adapter *adapter; in __ibmvnic_delayed_reset() local
3326 adapter = container_of(work, struct ibmvnic_adapter, in __ibmvnic_delayed_reset()
3328 __ibmvnic_reset(&adapter->ibmvnic_reset); in __ibmvnic_delayed_reset()
3331 static void flush_reset_queue(struct ibmvnic_adapter *adapter) in flush_reset_queue() argument
3335 if (!list_empty(&adapter->rwi_list)) { in flush_reset_queue()
3336 list_for_each_safe(entry, tmp_entry, &adapter->rwi_list) { in flush_reset_queue()
3343 static int ibmvnic_reset(struct ibmvnic_adapter *adapter, in ibmvnic_reset() argument
3346 struct net_device *netdev = adapter->netdev; in ibmvnic_reset()
3351 spin_lock_irqsave(&adapter->rwi_lock, flags); in ibmvnic_reset()
3358 if (adapter->state == VNIC_REMOVING || in ibmvnic_reset()
3359 adapter->state == VNIC_REMOVED || in ibmvnic_reset()
3360 (adapter->failover_pending && reason != VNIC_RESET_FAILOVER)) { in ibmvnic_reset()
3362 netdev_dbg(netdev, "Adapter removing or pending failover, skipping reset\n"); in ibmvnic_reset()
3366 list_for_each_entry(tmp, &adapter->rwi_list, list) { in ibmvnic_reset()
3383 if (adapter->force_reset_recovery) in ibmvnic_reset()
3384 flush_reset_queue(adapter); in ibmvnic_reset()
3387 list_add_tail(&rwi->list, &adapter->rwi_list); in ibmvnic_reset()
3388 netdev_dbg(adapter->netdev, "Scheduling reset (reason %s)\n", in ibmvnic_reset()
3390 queue_work(system_long_wq, &adapter->ibmvnic_reset); in ibmvnic_reset()
3395 spin_unlock_irqrestore(&adapter->rwi_lock, flags); in ibmvnic_reset()
3405 struct ibmvnic_adapter *adapter = netdev_priv(dev); in ibmvnic_tx_timeout() local
3407 if (test_bit(0, &adapter->resetting)) { in ibmvnic_tx_timeout()
3408 netdev_err(adapter->netdev, in ibmvnic_tx_timeout()
3409 "Adapter is resetting, skip timeout reset\n"); in ibmvnic_tx_timeout()
3415 if (time_before(jiffies, (adapter->last_reset_time + dev->watchdog_timeo))) { in ibmvnic_tx_timeout()
3419 ibmvnic_reset(adapter, VNIC_RESET_TIMEOUT); in ibmvnic_tx_timeout()
3422 static void remove_buff_from_pool(struct ibmvnic_adapter *adapter, in remove_buff_from_pool() argument
3425 struct ibmvnic_rx_pool *pool = &adapter->rx_pool[rx_buff->pool_index]; in remove_buff_from_pool()
3438 struct ibmvnic_adapter *adapter; in ibmvnic_poll() local
3444 adapter = netdev_priv(netdev); in ibmvnic_poll()
3445 scrq_num = (int)(napi - adapter->napi); in ibmvnic_poll()
3447 rx_scrq = adapter->rx_scrq[scrq_num]; in ibmvnic_poll()
3458 if (unlikely(test_bit(0, &adapter->resetting) && in ibmvnic_poll()
3459 adapter->reset_reason != VNIC_RESET_NON_FATAL)) { in ibmvnic_poll()
3460 enable_scrq_irq(adapter, rx_scrq); in ibmvnic_poll()
3465 if (!pending_scrq(adapter, rx_scrq)) in ibmvnic_poll()
3467 next = ibmvnic_next_scrq(adapter, rx_scrq); in ibmvnic_poll()
3477 remove_buff_from_pool(adapter, rx_buff); in ibmvnic_poll()
3482 remove_buff_from_pool(adapter, rx_buff); in ibmvnic_poll()
3498 if (adapter->rx_vlan_header_insertion && in ibmvnic_poll()
3505 remove_buff_from_pool(adapter, rx_buff); in ibmvnic_poll()
3520 adapter->rx_stats_buffers[scrq_num].packets++; in ibmvnic_poll()
3521 adapter->rx_stats_buffers[scrq_num].bytes += length; in ibmvnic_poll()
3525 if (adapter->state != VNIC_CLOSING && in ibmvnic_poll()
3526 ((atomic_read(&adapter->rx_pool[scrq_num].available) < in ibmvnic_poll()
3527 adapter->req_rx_add_entries_per_subcrq / 2) || in ibmvnic_poll()
3529 replenish_rx_pool(adapter, &adapter->rx_pool[scrq_num]); in ibmvnic_poll()
3532 enable_scrq_irq(adapter, rx_scrq); in ibmvnic_poll()
3533 if (pending_scrq(adapter, rx_scrq)) { in ibmvnic_poll()
3535 disable_scrq_irq(adapter, rx_scrq); in ibmvnic_poll()
3544 static int wait_for_reset(struct ibmvnic_adapter *adapter) in wait_for_reset() argument
3548 adapter->fallback.mtu = adapter->req_mtu; in wait_for_reset()
3549 adapter->fallback.rx_queues = adapter->req_rx_queues; in wait_for_reset()
3550 adapter->fallback.tx_queues = adapter->req_tx_queues; in wait_for_reset()
3551 adapter->fallback.rx_entries = adapter->req_rx_add_entries_per_subcrq; in wait_for_reset()
3552 adapter->fallback.tx_entries = adapter->req_tx_entries_per_subcrq; in wait_for_reset()
3554 reinit_completion(&adapter->reset_done); in wait_for_reset()
3555 adapter->wait_for_reset = true; in wait_for_reset()
3556 rc = ibmvnic_reset(adapter, VNIC_RESET_CHANGE_PARAM); in wait_for_reset()
3562 rc = ibmvnic_wait_for_completion(adapter, &adapter->reset_done, 60000); in wait_for_reset()
3569 if (adapter->reset_done_rc) { in wait_for_reset()
3571 adapter->desired.mtu = adapter->fallback.mtu; in wait_for_reset()
3572 adapter->desired.rx_queues = adapter->fallback.rx_queues; in wait_for_reset()
3573 adapter->desired.tx_queues = adapter->fallback.tx_queues; in wait_for_reset()
3574 adapter->desired.rx_entries = adapter->fallback.rx_entries; in wait_for_reset()
3575 adapter->desired.tx_entries = adapter->fallback.tx_entries; in wait_for_reset()
3577 reinit_completion(&adapter->reset_done); in wait_for_reset()
3578 adapter->wait_for_reset = true; in wait_for_reset()
3579 rc = ibmvnic_reset(adapter, VNIC_RESET_CHANGE_PARAM); in wait_for_reset()
3584 rc = ibmvnic_wait_for_completion(adapter, &adapter->reset_done, in wait_for_reset()
3592 adapter->wait_for_reset = false; in wait_for_reset()
3599 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_change_mtu() local
3601 adapter->desired.mtu = new_mtu + ETH_HLEN; in ibmvnic_change_mtu()
3603 return wait_for_reset(adapter); in ibmvnic_change_mtu()
3640 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_get_link_ksettings() local
3643 rc = send_query_phys_parms(adapter); in ibmvnic_get_link_ksettings()
3645 adapter->speed = SPEED_UNKNOWN; in ibmvnic_get_link_ksettings()
3646 adapter->duplex = DUPLEX_UNKNOWN; in ibmvnic_get_link_ksettings()
3648 cmd->base.speed = adapter->speed; in ibmvnic_get_link_ksettings()
3649 cmd->base.duplex = adapter->duplex; in ibmvnic_get_link_ksettings()
3660 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_get_drvinfo() local
3664 strscpy(info->fw_version, adapter->fw_version, in ibmvnic_get_drvinfo()
3670 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_get_msglevel() local
3672 return adapter->msg_enable; in ibmvnic_get_msglevel()
3677 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_set_msglevel() local
3679 adapter->msg_enable = data; in ibmvnic_set_msglevel()
3684 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_get_link() local
3689 return adapter->logical_link_state; in ibmvnic_get_link()
3697 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_get_ringparam() local
3699 ring->rx_max_pending = adapter->max_rx_add_entries_per_subcrq; in ibmvnic_get_ringparam()
3700 ring->tx_max_pending = adapter->max_tx_entries_per_subcrq; in ibmvnic_get_ringparam()
3703 ring->rx_pending = adapter->req_rx_add_entries_per_subcrq; in ibmvnic_get_ringparam()
3704 ring->tx_pending = adapter->req_tx_entries_per_subcrq; in ibmvnic_get_ringparam()
3714 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_set_ringparam() local
3716 if (ring->rx_pending > adapter->max_rx_add_entries_per_subcrq || in ibmvnic_set_ringparam()
3717 ring->tx_pending > adapter->max_tx_entries_per_subcrq) { in ibmvnic_set_ringparam()
3720 adapter->max_rx_add_entries_per_subcrq); in ibmvnic_set_ringparam()
3722 adapter->max_tx_entries_per_subcrq); in ibmvnic_set_ringparam()
3726 adapter->desired.rx_entries = ring->rx_pending; in ibmvnic_set_ringparam()
3727 adapter->desired.tx_entries = ring->tx_pending; in ibmvnic_set_ringparam()
3729 return wait_for_reset(adapter); in ibmvnic_set_ringparam()
3735 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_get_channels() local
3737 channels->max_rx = adapter->max_rx_queues; in ibmvnic_get_channels()
3738 channels->max_tx = adapter->max_tx_queues; in ibmvnic_get_channels()
3741 channels->rx_count = adapter->req_rx_queues; in ibmvnic_get_channels()
3742 channels->tx_count = adapter->req_tx_queues; in ibmvnic_get_channels()
3750 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_set_channels() local
3752 adapter->desired.rx_queues = channels->rx_count; in ibmvnic_set_channels()
3753 adapter->desired.tx_queues = channels->tx_count; in ibmvnic_set_channels()
3755 return wait_for_reset(adapter); in ibmvnic_set_channels()
3760 struct ibmvnic_adapter *adapter = netdev_priv(dev); in ibmvnic_get_strings() local
3769 for (i = 0; i < adapter->req_tx_queues; i++) { in ibmvnic_get_strings()
3780 for (i = 0; i < adapter->req_rx_queues; i++) { in ibmvnic_get_strings()
3794 struct ibmvnic_adapter *adapter = netdev_priv(dev); in ibmvnic_get_sset_count() local
3799 adapter->req_tx_queues * NUM_TX_STATS + in ibmvnic_get_sset_count()
3800 adapter->req_rx_queues * NUM_RX_STATS; in ibmvnic_get_sset_count()
3809 struct ibmvnic_adapter *adapter = netdev_priv(dev); in ibmvnic_get_ethtool_stats() local
3817 crq.request_statistics.ioba = cpu_to_be32(adapter->stats_token); in ibmvnic_get_ethtool_stats()
3822 reinit_completion(&adapter->stats_done); in ibmvnic_get_ethtool_stats()
3823 rc = ibmvnic_send_crq(adapter, &crq); in ibmvnic_get_ethtool_stats()
3826 rc = ibmvnic_wait_for_completion(adapter, &adapter->stats_done, 10000); in ibmvnic_get_ethtool_stats()
3832 (adapter, ibmvnic_stats[i].offset)); in ibmvnic_get_ethtool_stats()
3834 for (j = 0; j < adapter->req_tx_queues; j++) { in ibmvnic_get_ethtool_stats()
3835 data[i] = adapter->tx_stats_buffers[j].packets; in ibmvnic_get_ethtool_stats()
3837 data[i] = adapter->tx_stats_buffers[j].bytes; in ibmvnic_get_ethtool_stats()
3839 data[i] = adapter->tx_stats_buffers[j].dropped_packets; in ibmvnic_get_ethtool_stats()
3843 for (j = 0; j < adapter->req_rx_queues; j++) { in ibmvnic_get_ethtool_stats()
3844 data[i] = adapter->rx_stats_buffers[j].packets; in ibmvnic_get_ethtool_stats()
3846 data[i] = adapter->rx_stats_buffers[j].bytes; in ibmvnic_get_ethtool_stats()
3848 data[i] = adapter->rx_stats_buffers[j].interrupts; in ibmvnic_get_ethtool_stats()
3870 static int reset_one_sub_crq_queue(struct ibmvnic_adapter *adapter, in reset_one_sub_crq_queue() argument
3876 netdev_dbg(adapter->netdev, "Invalid scrq reset.\n"); in reset_one_sub_crq_queue()
3892 netdev_dbg(adapter->netdev, "Invalid scrq reset\n"); in reset_one_sub_crq_queue()
3896 rc = h_reg_sub_crq(adapter->vdev->unit_address, scrq->msg_token, in reset_one_sub_crq_queue()
3901 static int reset_sub_crq_queues(struct ibmvnic_adapter *adapter) in reset_sub_crq_queues() argument
3905 if (!adapter->tx_scrq || !adapter->rx_scrq) in reset_sub_crq_queues()
3908 ibmvnic_clean_affinity(adapter); in reset_sub_crq_queues()
3910 for (i = 0; i < adapter->req_tx_queues; i++) { in reset_sub_crq_queues()
3911 netdev_dbg(adapter->netdev, "Re-setting tx_scrq[%d]\n", i); in reset_sub_crq_queues()
3912 rc = reset_one_sub_crq_queue(adapter, adapter->tx_scrq[i]); in reset_sub_crq_queues()
3917 for (i = 0; i < adapter->req_rx_queues; i++) { in reset_sub_crq_queues()
3918 netdev_dbg(adapter->netdev, "Re-setting rx_scrq[%d]\n", i); in reset_sub_crq_queues()
3919 rc = reset_one_sub_crq_queue(adapter, adapter->rx_scrq[i]); in reset_sub_crq_queues()
3927 static void release_sub_crq_queue(struct ibmvnic_adapter *adapter, in release_sub_crq_queue() argument
3931 struct device *dev = &adapter->vdev->dev; in release_sub_crq_queue()
3934 netdev_dbg(adapter->netdev, "Releasing sub-CRQ\n"); in release_sub_crq_queue()
3940 adapter->vdev->unit_address, in release_sub_crq_queue()
3945 netdev_err(adapter->netdev, in release_sub_crq_queue()
3964 *adapter) in init_sub_crq_queue()
3966 struct device *dev = &adapter->vdev->dev; in init_sub_crq_queue()
3990 rc = h_reg_sub_crq(adapter->vdev->unit_address, scrq->msg_token, in init_sub_crq_queue()
3994 rc = ibmvnic_reset_crq(adapter); in init_sub_crq_queue()
3997 dev_warn(dev, "Partner adapter not ready, waiting.\n"); in init_sub_crq_queue()
4003 scrq->adapter = adapter; in init_sub_crq_queue()
4018 netdev_dbg(adapter->netdev, in init_sub_crq_queue()
4027 adapter->vdev->unit_address, in init_sub_crq_queue()
4043 static void release_sub_crqs(struct ibmvnic_adapter *adapter, bool do_h_free) in release_sub_crqs() argument
4047 ibmvnic_clean_affinity(adapter); in release_sub_crqs()
4048 if (adapter->tx_scrq) { in release_sub_crqs()
4049 for (i = 0; i < adapter->num_active_tx_scrqs; i++) { in release_sub_crqs()
4050 if (!adapter->tx_scrq[i]) in release_sub_crqs()
4053 netdev_dbg(adapter->netdev, "Releasing tx_scrq[%d]\n", in release_sub_crqs()
4055 ibmvnic_tx_scrq_clean_buffer(adapter, adapter->tx_scrq[i]); in release_sub_crqs()
4056 if (adapter->tx_scrq[i]->irq) { in release_sub_crqs()
4057 free_irq(adapter->tx_scrq[i]->irq, in release_sub_crqs()
4058 adapter->tx_scrq[i]); in release_sub_crqs()
4059 irq_dispose_mapping(adapter->tx_scrq[i]->irq); in release_sub_crqs()
4060 adapter->tx_scrq[i]->irq = 0; in release_sub_crqs()
4063 release_sub_crq_queue(adapter, adapter->tx_scrq[i], in release_sub_crqs()
4067 kfree(adapter->tx_scrq); in release_sub_crqs()
4068 adapter->tx_scrq = NULL; in release_sub_crqs()
4069 adapter->num_active_tx_scrqs = 0; in release_sub_crqs()
4076 clean_tx_pools(adapter); in release_sub_crqs()
4078 if (adapter->rx_scrq) { in release_sub_crqs()
4079 for (i = 0; i < adapter->num_active_rx_scrqs; i++) { in release_sub_crqs()
4080 if (!adapter->rx_scrq[i]) in release_sub_crqs()
4083 netdev_dbg(adapter->netdev, "Releasing rx_scrq[%d]\n", in release_sub_crqs()
4085 if (adapter->rx_scrq[i]->irq) { in release_sub_crqs()
4086 free_irq(adapter->rx_scrq[i]->irq, in release_sub_crqs()
4087 adapter->rx_scrq[i]); in release_sub_crqs()
4088 irq_dispose_mapping(adapter->rx_scrq[i]->irq); in release_sub_crqs()
4089 adapter->rx_scrq[i]->irq = 0; in release_sub_crqs()
4092 release_sub_crq_queue(adapter, adapter->rx_scrq[i], in release_sub_crqs()
4096 kfree(adapter->rx_scrq); in release_sub_crqs()
4097 adapter->rx_scrq = NULL; in release_sub_crqs()
4098 adapter->num_active_rx_scrqs = 0; in release_sub_crqs()
4102 static int disable_scrq_irq(struct ibmvnic_adapter *adapter, in disable_scrq_irq() argument
4105 struct device *dev = &adapter->vdev->dev; in disable_scrq_irq()
4108 rc = plpar_hcall_norets(H_VIOCTL, adapter->vdev->unit_address, in disable_scrq_irq()
4140 static int enable_scrq_irq(struct ibmvnic_adapter *adapter, in enable_scrq_irq() argument
4143 struct device *dev = &adapter->vdev->dev; in enable_scrq_irq()
4151 if (test_bit(0, &adapter->resetting) && in enable_scrq_irq()
4152 adapter->reset_reason == VNIC_RESET_MOBILITY) { in enable_scrq_irq()
4156 rc = plpar_hcall_norets(H_VIOCTL, adapter->vdev->unit_address, in enable_scrq_irq()
4164 static int ibmvnic_complete_tx(struct ibmvnic_adapter *adapter, in ibmvnic_complete_tx() argument
4167 struct device *dev = &adapter->vdev->dev; in ibmvnic_complete_tx()
4176 while (pending_scrq(adapter, scrq)) { in ibmvnic_complete_tx()
4182 next = ibmvnic_next_scrq(adapter, scrq); in ibmvnic_complete_tx()
4186 tx_pool = &adapter->tso_pool[pool]; in ibmvnic_complete_tx()
4189 tx_pool = &adapter->tx_pool[pool]; in ibmvnic_complete_tx()
4206 netdev_warn(adapter->netdev, in ibmvnic_complete_tx()
4217 txq = netdev_get_tx_queue(adapter->netdev, scrq->pool_index); in ibmvnic_complete_tx()
4221 (adapter->req_tx_entries_per_subcrq / 2) && in ibmvnic_complete_tx()
4222 __netif_subqueue_stopped(adapter->netdev, in ibmvnic_complete_tx()
4225 if (adapter->tx_queues_active) { in ibmvnic_complete_tx()
4226 netif_wake_subqueue(adapter->netdev, in ibmvnic_complete_tx()
4228 netdev_dbg(adapter->netdev, in ibmvnic_complete_tx()
4236 enable_scrq_irq(adapter, scrq); in ibmvnic_complete_tx()
4238 if (pending_scrq(adapter, scrq)) { in ibmvnic_complete_tx()
4239 disable_scrq_irq(adapter, scrq); in ibmvnic_complete_tx()
4249 struct ibmvnic_adapter *adapter = scrq->adapter; in ibmvnic_interrupt_tx() local
4251 disable_scrq_irq(adapter, scrq); in ibmvnic_interrupt_tx()
4252 ibmvnic_complete_tx(adapter, scrq); in ibmvnic_interrupt_tx()
4260 struct ibmvnic_adapter *adapter = scrq->adapter; in ibmvnic_interrupt_rx() local
4265 if (unlikely(adapter->state != VNIC_OPEN)) in ibmvnic_interrupt_rx()
4268 adapter->rx_stats_buffers[scrq->scrq_num].interrupts++; in ibmvnic_interrupt_rx()
4270 if (napi_schedule_prep(&adapter->napi[scrq->scrq_num])) { in ibmvnic_interrupt_rx()
4271 disable_scrq_irq(adapter, scrq); in ibmvnic_interrupt_rx()
4272 __napi_schedule(&adapter->napi[scrq->scrq_num]); in ibmvnic_interrupt_rx()
4278 static int init_sub_crq_irqs(struct ibmvnic_adapter *adapter) in init_sub_crq_irqs() argument
4280 struct device *dev = &adapter->vdev->dev; in init_sub_crq_irqs()
4285 for (i = 0; i < adapter->req_tx_queues; i++) { in init_sub_crq_irqs()
4286 netdev_dbg(adapter->netdev, "Initializing tx_scrq[%d] irq\n", in init_sub_crq_irqs()
4288 scrq = adapter->tx_scrq[i]; in init_sub_crq_irqs()
4298 adapter->vdev->unit_address, i); in init_sub_crq_irqs()
4310 for (i = 0; i < adapter->req_rx_queues; i++) { in init_sub_crq_irqs()
4311 netdev_dbg(adapter->netdev, "Initializing rx_scrq[%d] irq\n", in init_sub_crq_irqs()
4313 scrq = adapter->rx_scrq[i]; in init_sub_crq_irqs()
4321 adapter->vdev->unit_address, i); in init_sub_crq_irqs()
4333 ibmvnic_set_affinity(adapter); in init_sub_crq_irqs()
4340 free_irq(adapter->rx_scrq[j]->irq, adapter->rx_scrq[j]); in init_sub_crq_irqs()
4341 irq_dispose_mapping(adapter->rx_scrq[j]->irq); in init_sub_crq_irqs()
4343 i = adapter->req_tx_queues; in init_sub_crq_irqs()
4346 free_irq(adapter->tx_scrq[j]->irq, adapter->tx_scrq[j]); in init_sub_crq_irqs()
4347 irq_dispose_mapping(adapter->tx_scrq[j]->irq); in init_sub_crq_irqs()
4349 release_sub_crqs(adapter, 1); in init_sub_crq_irqs()
4353 static int init_sub_crqs(struct ibmvnic_adapter *adapter) in init_sub_crqs() argument
4355 struct device *dev = &adapter->vdev->dev; in init_sub_crqs()
4362 total_queues = adapter->req_tx_queues + adapter->req_rx_queues; in init_sub_crqs()
4369 allqueues[i] = init_sub_crq_queue(adapter); in init_sub_crqs()
4379 adapter->min_tx_queues + adapter->min_rx_queues) { in init_sub_crqs()
4386 netdev_dbg(adapter->netdev, "Reducing number of queues\n"); in init_sub_crqs()
4389 if (adapter->req_rx_queues > adapter->min_rx_queues) in init_sub_crqs()
4390 adapter->req_rx_queues--; in init_sub_crqs()
4395 if (adapter->req_tx_queues > adapter->min_tx_queues) in init_sub_crqs()
4396 adapter->req_tx_queues--; in init_sub_crqs()
4403 adapter->tx_scrq = kcalloc(adapter->req_tx_queues, in init_sub_crqs()
4404 sizeof(*adapter->tx_scrq), GFP_KERNEL); in init_sub_crqs()
4405 if (!adapter->tx_scrq) in init_sub_crqs()
4408 for (i = 0; i < adapter->req_tx_queues; i++) { in init_sub_crqs()
4409 adapter->tx_scrq[i] = allqueues[i]; in init_sub_crqs()
4410 adapter->tx_scrq[i]->pool_index = i; in init_sub_crqs()
4411 adapter->num_active_tx_scrqs++; in init_sub_crqs()
4414 adapter->rx_scrq = kcalloc(adapter->req_rx_queues, in init_sub_crqs()
4415 sizeof(*adapter->rx_scrq), GFP_KERNEL); in init_sub_crqs()
4416 if (!adapter->rx_scrq) in init_sub_crqs()
4419 for (i = 0; i < adapter->req_rx_queues; i++) { in init_sub_crqs()
4420 adapter->rx_scrq[i] = allqueues[i + adapter->req_tx_queues]; in init_sub_crqs()
4421 adapter->rx_scrq[i]->scrq_num = i; in init_sub_crqs()
4422 adapter->num_active_rx_scrqs++; in init_sub_crqs()
4429 kfree(adapter->tx_scrq); in init_sub_crqs()
4430 adapter->tx_scrq = NULL; in init_sub_crqs()
4433 release_sub_crq_queue(adapter, allqueues[i], 1); in init_sub_crqs()
4438 static void send_request_cap(struct ibmvnic_adapter *adapter, int retry) in send_request_cap() argument
4440 struct device *dev = &adapter->vdev->dev; in send_request_cap()
4450 if (!(adapter->netdev->flags & IFF_PROMISC) || in send_request_cap()
4451 adapter->promisc_supported) in send_request_cap()
4460 atomic_set(&adapter->running_cap_crqs, cap_reqs); in send_request_cap()
4462 if (adapter->min_tx_entries_per_subcrq > entries_page || in send_request_cap()
4463 adapter->min_rx_add_entries_per_subcrq > entries_page) { in send_request_cap()
4468 if (adapter->desired.mtu) in send_request_cap()
4469 adapter->req_mtu = adapter->desired.mtu; in send_request_cap()
4471 adapter->req_mtu = adapter->netdev->mtu + ETH_HLEN; in send_request_cap()
4473 if (!adapter->desired.tx_entries) in send_request_cap()
4474 adapter->desired.tx_entries = in send_request_cap()
4475 adapter->max_tx_entries_per_subcrq; in send_request_cap()
4476 if (!adapter->desired.rx_entries) in send_request_cap()
4477 adapter->desired.rx_entries = in send_request_cap()
4478 adapter->max_rx_add_entries_per_subcrq; in send_request_cap()
4481 (adapter->req_mtu + IBMVNIC_BUFFER_HLEN); in send_request_cap()
4483 if ((adapter->req_mtu + IBMVNIC_BUFFER_HLEN) * in send_request_cap()
4484 adapter->desired.tx_entries > IBMVNIC_LTB_SET_SIZE) { in send_request_cap()
4485 adapter->desired.tx_entries = max_entries; in send_request_cap()
4488 if ((adapter->req_mtu + IBMVNIC_BUFFER_HLEN) * in send_request_cap()
4489 adapter->desired.rx_entries > IBMVNIC_LTB_SET_SIZE) { in send_request_cap()
4490 adapter->desired.rx_entries = max_entries; in send_request_cap()
4493 if (adapter->desired.tx_entries) in send_request_cap()
4494 adapter->req_tx_entries_per_subcrq = in send_request_cap()
4495 adapter->desired.tx_entries; in send_request_cap()
4497 adapter->req_tx_entries_per_subcrq = in send_request_cap()
4498 adapter->max_tx_entries_per_subcrq; in send_request_cap()
4500 if (adapter->desired.rx_entries) in send_request_cap()
4501 adapter->req_rx_add_entries_per_subcrq = in send_request_cap()
4502 adapter->desired.rx_entries; in send_request_cap()
4504 adapter->req_rx_add_entries_per_subcrq = in send_request_cap()
4505 adapter->max_rx_add_entries_per_subcrq; in send_request_cap()
4507 if (adapter->desired.tx_queues) in send_request_cap()
4508 adapter->req_tx_queues = in send_request_cap()
4509 adapter->desired.tx_queues; in send_request_cap()
4511 adapter->req_tx_queues = in send_request_cap()
4512 adapter->opt_tx_comp_sub_queues; in send_request_cap()
4514 if (adapter->desired.rx_queues) in send_request_cap()
4515 adapter->req_rx_queues = in send_request_cap()
4516 adapter->desired.rx_queues; in send_request_cap()
4518 adapter->req_rx_queues = in send_request_cap()
4519 adapter->opt_rx_comp_queues; in send_request_cap()
4521 adapter->req_rx_add_queues = adapter->max_rx_add_queues; in send_request_cap()
4523 atomic_add(cap_reqs, &adapter->running_cap_crqs); in send_request_cap()
4530 crq.request_capability.number = cpu_to_be64(adapter->req_tx_queues); in send_request_cap()
4532 ibmvnic_send_crq(adapter, &crq); in send_request_cap()
4535 crq.request_capability.number = cpu_to_be64(adapter->req_rx_queues); in send_request_cap()
4537 ibmvnic_send_crq(adapter, &crq); in send_request_cap()
4540 crq.request_capability.number = cpu_to_be64(adapter->req_rx_add_queues); in send_request_cap()
4542 ibmvnic_send_crq(adapter, &crq); in send_request_cap()
4547 cpu_to_be64(adapter->req_tx_entries_per_subcrq); in send_request_cap()
4549 ibmvnic_send_crq(adapter, &crq); in send_request_cap()
4554 cpu_to_be64(adapter->req_rx_add_entries_per_subcrq); in send_request_cap()
4556 ibmvnic_send_crq(adapter, &crq); in send_request_cap()
4559 crq.request_capability.number = cpu_to_be64(adapter->req_mtu); in send_request_cap()
4561 ibmvnic_send_crq(adapter, &crq); in send_request_cap()
4563 if (adapter->netdev->flags & IFF_PROMISC) { in send_request_cap()
4564 if (adapter->promisc_supported) { in send_request_cap()
4569 ibmvnic_send_crq(adapter, &crq); in send_request_cap()
4576 ibmvnic_send_crq(adapter, &crq); in send_request_cap()
4585 static int pending_scrq(struct ibmvnic_adapter *adapter, in pending_scrq() argument
4601 static union sub_crq *ibmvnic_next_scrq(struct ibmvnic_adapter *adapter, in ibmvnic_next_scrq() argument
4625 static union ibmvnic_crq *ibmvnic_next_crq(struct ibmvnic_adapter *adapter) in ibmvnic_next_crq() argument
4627 struct ibmvnic_crq_queue *queue = &adapter->crq; in ibmvnic_next_crq()
4646 "%s failed: Send request is malformed or adapter failover pending. (rc=%d)\n", in print_subcrq_error()
4651 "%s failed: Backing queue closed. Adapter is down or failover pending. (rc=%d)\n", in print_subcrq_error()
4660 static int send_subcrq_indirect(struct ibmvnic_adapter *adapter, in send_subcrq_indirect() argument
4663 unsigned int ua = adapter->vdev->unit_address; in send_subcrq_indirect()
4664 struct device *dev = &adapter->vdev->dev; in send_subcrq_indirect()
4679 static int ibmvnic_send_crq(struct ibmvnic_adapter *adapter, in ibmvnic_send_crq() argument
4682 unsigned int ua = adapter->vdev->unit_address; in ibmvnic_send_crq()
4683 struct device *dev = &adapter->vdev->dev; in ibmvnic_send_crq()
4687 netdev_dbg(adapter->netdev, "Sending CRQ: %016lx %016lx\n", in ibmvnic_send_crq()
4691 if (!adapter->crq.active && in ibmvnic_send_crq()
4716 static int ibmvnic_send_crq_init(struct ibmvnic_adapter *adapter) in ibmvnic_send_crq_init() argument
4718 struct device *dev = &adapter->vdev->dev; in ibmvnic_send_crq_init()
4726 netdev_dbg(adapter->netdev, "Sending CRQ init\n"); in ibmvnic_send_crq_init()
4729 rc = ibmvnic_send_crq(adapter, &crq); in ibmvnic_send_crq_init()
4751 static int vnic_client_data_len(struct ibmvnic_adapter *adapter) in vnic_client_data_len() argument
4762 len += strlen(adapter->netdev->name) + 1; in vnic_client_data_len()
4767 static void vnic_add_client_data(struct ibmvnic_adapter *adapter, in vnic_add_client_data() argument
4789 len = strlen(adapter->netdev->name) + 1; in vnic_add_client_data()
4791 strscpy(vlcd->name, adapter->netdev->name, len); in vnic_add_client_data()
4794 static int send_login(struct ibmvnic_adapter *adapter) in send_login() argument
4798 struct device *dev = &adapter->vdev->dev; in send_login()
4811 if (!adapter->tx_scrq || !adapter->rx_scrq) { in send_login()
4812 netdev_err(adapter->netdev, in send_login()
4817 release_login_buffer(adapter); in send_login()
4818 release_login_rsp_buffer(adapter); in send_login()
4820 client_data_len = vnic_client_data_len(adapter); in send_login()
4824 sizeof(u64) * (adapter->req_tx_queues + adapter->req_rx_queues) + in send_login()
4839 sizeof(u64) * adapter->req_tx_queues + in send_login()
4840 sizeof(u64) * adapter->req_rx_queues + in send_login()
4841 sizeof(u64) * adapter->req_rx_queues + in send_login()
4855 adapter->login_buf = login_buffer; in send_login()
4856 adapter->login_buf_token = buffer_token; in send_login()
4857 adapter->login_buf_sz = buffer_size; in send_login()
4858 adapter->login_rsp_buf = login_rsp_buffer; in send_login()
4859 adapter->login_rsp_buf_token = rsp_buffer_token; in send_login()
4860 adapter->login_rsp_buf_sz = rsp_buffer_size; in send_login()
4864 login_buffer->num_txcomp_subcrqs = cpu_to_be32(adapter->req_tx_queues); in send_login()
4867 login_buffer->num_rxcomp_subcrqs = cpu_to_be32(adapter->req_rx_queues); in send_login()
4870 sizeof(u64) * adapter->req_tx_queues); in send_login()
4878 sizeof(u64) * adapter->req_tx_queues); in send_login()
4880 for (i = 0; i < adapter->req_tx_queues; i++) { in send_login()
4881 if (adapter->tx_scrq[i]) { in send_login()
4883 cpu_to_be64(adapter->tx_scrq[i]->crq_num); in send_login()
4887 for (i = 0; i < adapter->req_rx_queues; i++) { in send_login()
4888 if (adapter->rx_scrq[i]) { in send_login()
4890 cpu_to_be64(adapter->rx_scrq[i]->crq_num); in send_login()
4896 ((char *)rx_list_p + (sizeof(u64) * adapter->req_rx_queues)); in send_login()
4901 vnic_add_client_data(adapter, vlcd); in send_login()
4903 netdev_dbg(adapter->netdev, "Login Buffer:\n"); in send_login()
4904 for (i = 0; i < (adapter->login_buf_sz - 1) / 8 + 1; i++) { in send_login()
4905 netdev_dbg(adapter->netdev, "%016lx\n", in send_login()
4906 ((unsigned long *)(adapter->login_buf))[i]); in send_login()
4915 adapter->login_pending = true; in send_login()
4916 rc = ibmvnic_send_crq(adapter, &crq); in send_login()
4918 adapter->login_pending = false; in send_login()
4919 netdev_err(adapter->netdev, "Failed to send login, rc=%d\n", rc); in send_login()
4930 adapter->login_rsp_buf = NULL; in send_login()
4935 adapter->login_buf = NULL; in send_login()
4940 static int send_request_map(struct ibmvnic_adapter *adapter, dma_addr_t addr, in send_request_map() argument
4951 return ibmvnic_send_crq(adapter, &crq); in send_request_map()
4954 static int send_request_unmap(struct ibmvnic_adapter *adapter, u8 map_id) in send_request_unmap() argument
4962 return ibmvnic_send_crq(adapter, &crq); in send_request_unmap()
4965 static void send_query_map(struct ibmvnic_adapter *adapter) in send_query_map() argument
4972 ibmvnic_send_crq(adapter, &crq); in send_query_map()
4976 static void send_query_cap(struct ibmvnic_adapter *adapter) in send_query_cap() argument
4987 atomic_set(&adapter->running_cap_crqs, cap_reqs); in send_query_cap()
4994 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
4998 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5002 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5006 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5010 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5014 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5019 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5024 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5029 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5034 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5038 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5042 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5046 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5050 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5054 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5058 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5062 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5066 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5070 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5074 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5078 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5083 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5088 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5093 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5098 ibmvnic_send_crq(adapter, &crq); in send_query_cap()
5107 static void send_query_ip_offload(struct ibmvnic_adapter *adapter) in send_query_ip_offload() argument
5110 struct device *dev = &adapter->vdev->dev; in send_query_ip_offload()
5113 adapter->ip_offload_tok = in send_query_ip_offload()
5115 &adapter->ip_offload_buf, in send_query_ip_offload()
5119 if (dma_mapping_error(dev, adapter->ip_offload_tok)) { in send_query_ip_offload()
5130 cpu_to_be32(adapter->ip_offload_tok); in send_query_ip_offload()
5132 ibmvnic_send_crq(adapter, &crq); in send_query_ip_offload()
5135 static void send_control_ip_offload(struct ibmvnic_adapter *adapter) in send_control_ip_offload() argument
5137 struct ibmvnic_control_ip_offload_buffer *ctrl_buf = &adapter->ip_offload_ctrl; in send_control_ip_offload()
5138 struct ibmvnic_query_ip_offload_buffer *buf = &adapter->ip_offload_buf; in send_control_ip_offload()
5139 struct device *dev = &adapter->vdev->dev; in send_control_ip_offload()
5143 adapter->ip_offload_ctrl_tok = in send_control_ip_offload()
5146 sizeof(adapter->ip_offload_ctrl), in send_control_ip_offload()
5149 if (dma_mapping_error(dev, adapter->ip_offload_ctrl_tok)) { in send_control_ip_offload()
5154 ctrl_buf->len = cpu_to_be32(sizeof(adapter->ip_offload_ctrl)); in send_control_ip_offload()
5169 if (adapter->state != VNIC_PROBING) { in send_control_ip_offload()
5170 old_hw_features = adapter->netdev->hw_features; in send_control_ip_offload()
5171 adapter->netdev->hw_features = 0; in send_control_ip_offload()
5174 adapter->netdev->hw_features = NETIF_F_SG | NETIF_F_GSO | NETIF_F_GRO; in send_control_ip_offload()
5177 adapter->netdev->hw_features |= NETIF_F_IP_CSUM; in send_control_ip_offload()
5180 adapter->netdev->hw_features |= NETIF_F_IPV6_CSUM; in send_control_ip_offload()
5182 if ((adapter->netdev->features & in send_control_ip_offload()
5184 adapter->netdev->hw_features |= NETIF_F_RXCSUM; in send_control_ip_offload()
5187 adapter->netdev->hw_features |= NETIF_F_TSO; in send_control_ip_offload()
5189 adapter->netdev->hw_features |= NETIF_F_TSO6; in send_control_ip_offload()
5191 if (adapter->state == VNIC_PROBING) { in send_control_ip_offload()
5192 adapter->netdev->features |= adapter->netdev->hw_features; in send_control_ip_offload()
5193 } else if (old_hw_features != adapter->netdev->hw_features) { in send_control_ip_offload()
5197 adapter->netdev->features &= adapter->netdev->hw_features; in send_control_ip_offload()
5199 tmp = (old_hw_features ^ adapter->netdev->hw_features) & in send_control_ip_offload()
5200 adapter->netdev->hw_features; in send_control_ip_offload()
5201 adapter->netdev->features |= in send_control_ip_offload()
5202 tmp & adapter->netdev->wanted_features; in send_control_ip_offload()
5209 cpu_to_be32(sizeof(adapter->ip_offload_ctrl)); in send_control_ip_offload()
5210 crq.control_ip_offload.ioba = cpu_to_be32(adapter->ip_offload_ctrl_tok); in send_control_ip_offload()
5211 ibmvnic_send_crq(adapter, &crq); in send_control_ip_offload()
5215 struct ibmvnic_adapter *adapter) in handle_vpd_size_rsp() argument
5217 struct device *dev = &adapter->vdev->dev; in handle_vpd_size_rsp()
5222 complete(&adapter->fw_done); in handle_vpd_size_rsp()
5226 adapter->vpd->len = be64_to_cpu(crq->get_vpd_size_rsp.len); in handle_vpd_size_rsp()
5227 complete(&adapter->fw_done); in handle_vpd_size_rsp()
5231 struct ibmvnic_adapter *adapter) in handle_vpd_rsp() argument
5233 struct device *dev = &adapter->vdev->dev; in handle_vpd_rsp()
5237 memset(adapter->fw_version, 0, 32); in handle_vpd_rsp()
5239 dma_unmap_single(dev, adapter->vpd->dma_addr, adapter->vpd->len, in handle_vpd_rsp()
5251 substr = strnstr(adapter->vpd->buff, "RM", adapter->vpd->len); in handle_vpd_rsp()
5258 if ((substr + 2) < (adapter->vpd->buff + adapter->vpd->len)) { in handle_vpd_rsp()
5265 /* copy firmware version string from vpd into adapter */ in handle_vpd_rsp()
5267 (adapter->vpd->buff + adapter->vpd->len)) { in handle_vpd_rsp()
5268 strncpy((char *)adapter->fw_version, substr + 3, fw_level_len); in handle_vpd_rsp()
5274 if (adapter->fw_version[0] == '\0') in handle_vpd_rsp()
5275 strscpy((char *)adapter->fw_version, "N/A", sizeof(adapter->fw_version)); in handle_vpd_rsp()
5276 complete(&adapter->fw_done); in handle_vpd_rsp()
5279 static void handle_query_ip_offload_rsp(struct ibmvnic_adapter *adapter) in handle_query_ip_offload_rsp() argument
5281 struct device *dev = &adapter->vdev->dev; in handle_query_ip_offload_rsp()
5282 struct ibmvnic_query_ip_offload_buffer *buf = &adapter->ip_offload_buf; in handle_query_ip_offload_rsp()
5285 dma_unmap_single(dev, adapter->ip_offload_tok, in handle_query_ip_offload_rsp()
5286 sizeof(adapter->ip_offload_buf), DMA_FROM_DEVICE); in handle_query_ip_offload_rsp()
5288 netdev_dbg(adapter->netdev, "Query IP Offload Buffer:\n"); in handle_query_ip_offload_rsp()
5289 for (i = 0; i < (sizeof(adapter->ip_offload_buf) - 1) / 8 + 1; i++) in handle_query_ip_offload_rsp()
5290 netdev_dbg(adapter->netdev, "%016lx\n", in handle_query_ip_offload_rsp()
5293 netdev_dbg(adapter->netdev, "ipv4_chksum = %d\n", buf->ipv4_chksum); in handle_query_ip_offload_rsp()
5294 netdev_dbg(adapter->netdev, "ipv6_chksum = %d\n", buf->ipv6_chksum); in handle_query_ip_offload_rsp()
5295 netdev_dbg(adapter->netdev, "tcp_ipv4_chksum = %d\n", in handle_query_ip_offload_rsp()
5297 netdev_dbg(adapter->netdev, "tcp_ipv6_chksum = %d\n", in handle_query_ip_offload_rsp()
5299 netdev_dbg(adapter->netdev, "udp_ipv4_chksum = %d\n", in handle_query_ip_offload_rsp()
5301 netdev_dbg(adapter->netdev, "udp_ipv6_chksum = %d\n", in handle_query_ip_offload_rsp()
5303 netdev_dbg(adapter->netdev, "large_tx_ipv4 = %d\n", in handle_query_ip_offload_rsp()
5305 netdev_dbg(adapter->netdev, "large_tx_ipv6 = %d\n", in handle_query_ip_offload_rsp()
5307 netdev_dbg(adapter->netdev, "large_rx_ipv4 = %d\n", in handle_query_ip_offload_rsp()
5309 netdev_dbg(adapter->netdev, "large_rx_ipv6 = %d\n", in handle_query_ip_offload_rsp()
5311 netdev_dbg(adapter->netdev, "max_ipv4_hdr_sz = %d\n", in handle_query_ip_offload_rsp()
5313 netdev_dbg(adapter->netdev, "max_ipv6_hdr_sz = %d\n", in handle_query_ip_offload_rsp()
5315 netdev_dbg(adapter->netdev, "max_tcp_hdr_size = %d\n", in handle_query_ip_offload_rsp()
5317 netdev_dbg(adapter->netdev, "max_udp_hdr_size = %d\n", in handle_query_ip_offload_rsp()
5319 netdev_dbg(adapter->netdev, "max_large_tx_size = %d\n", in handle_query_ip_offload_rsp()
5321 netdev_dbg(adapter->netdev, "max_large_rx_size = %d\n", in handle_query_ip_offload_rsp()
5323 netdev_dbg(adapter->netdev, "ipv6_ext_hdr = %d\n", in handle_query_ip_offload_rsp()
5325 netdev_dbg(adapter->netdev, "tcp_pseudosum_req = %d\n", in handle_query_ip_offload_rsp()
5327 netdev_dbg(adapter->netdev, "num_ipv6_ext_hd = %d\n", in handle_query_ip_offload_rsp()
5329 netdev_dbg(adapter->netdev, "off_ipv6_ext_hd = %d\n", in handle_query_ip_offload_rsp()
5332 send_control_ip_offload(adapter); in handle_query_ip_offload_rsp()
5339 return "adapter problem"; in ibmvnic_fw_err_cause()
5358 struct ibmvnic_adapter *adapter) in handle_error_indication() argument
5360 struct device *dev = &adapter->vdev->dev; in handle_error_indication()
5372 ibmvnic_reset(adapter, VNIC_RESET_FATAL); in handle_error_indication()
5374 ibmvnic_reset(adapter, VNIC_RESET_NON_FATAL); in handle_error_indication()
5378 struct ibmvnic_adapter *adapter) in handle_change_mac_rsp() argument
5380 struct net_device *netdev = adapter->netdev; in handle_change_mac_rsp()
5381 struct device *dev = &adapter->vdev->dev; in handle_change_mac_rsp()
5393 ether_addr_copy(adapter->mac_addr, in handle_change_mac_rsp()
5396 complete(&adapter->fw_done); in handle_change_mac_rsp()
5401 struct ibmvnic_adapter *adapter) in handle_request_cap_rsp() argument
5403 struct device *dev = &adapter->vdev->dev; in handle_request_cap_rsp()
5407 atomic_dec(&adapter->running_cap_crqs); in handle_request_cap_rsp()
5408 netdev_dbg(adapter->netdev, "Outstanding request-caps: %d\n", in handle_request_cap_rsp()
5409 atomic_read(&adapter->running_cap_crqs)); in handle_request_cap_rsp()
5412 req_value = &adapter->req_tx_queues; in handle_request_cap_rsp()
5416 req_value = &adapter->req_rx_queues; in handle_request_cap_rsp()
5420 req_value = &adapter->req_rx_add_queues; in handle_request_cap_rsp()
5424 req_value = &adapter->req_tx_entries_per_subcrq; in handle_request_cap_rsp()
5428 req_value = &adapter->req_rx_add_entries_per_subcrq; in handle_request_cap_rsp()
5432 req_value = &adapter->req_mtu; in handle_request_cap_rsp()
5436 req_value = &adapter->promisc; in handle_request_cap_rsp()
5458 *req_value = adapter->fallback.mtu; in handle_request_cap_rsp()
5464 send_request_cap(adapter, 1); in handle_request_cap_rsp()
5473 if (atomic_read(&adapter->running_cap_crqs) == 0) in handle_request_cap_rsp()
5474 send_query_ip_offload(adapter); in handle_request_cap_rsp()
5478 struct ibmvnic_adapter *adapter) in handle_login_rsp() argument
5480 struct device *dev = &adapter->vdev->dev; in handle_login_rsp()
5481 struct net_device *netdev = adapter->netdev; in handle_login_rsp()
5482 struct ibmvnic_login_rsp_buffer *login_rsp = adapter->login_rsp_buf; in handle_login_rsp()
5483 struct ibmvnic_login_buffer *login = adapter->login_buf; in handle_login_rsp()
5495 if (!adapter->login_pending) { in handle_login_rsp()
5499 adapter->login_pending = false; in handle_login_rsp()
5506 adapter->init_done_rc = login_rsp_crq->generic.rc.code; in handle_login_rsp()
5507 complete(&adapter->init_done); in handle_login_rsp()
5511 if (adapter->failover_pending) { in handle_login_rsp()
5512 adapter->init_done_rc = -EAGAIN; in handle_login_rsp()
5514 complete(&adapter->init_done); in handle_login_rsp()
5519 netdev->mtu = adapter->req_mtu - ETH_HLEN; in handle_login_rsp()
5521 netdev_dbg(adapter->netdev, "Login Response Buffer:\n"); in handle_login_rsp()
5522 for (i = 0; i < (adapter->login_rsp_buf_sz - 1) / 8 + 1; i++) { in handle_login_rsp()
5523 netdev_dbg(adapter->netdev, "%016lx\n", in handle_login_rsp()
5524 ((unsigned long *)(adapter->login_rsp_buf))[i]); in handle_login_rsp()
5530 adapter->req_rx_add_queues != in handle_login_rsp()
5533 ibmvnic_reset(adapter, VNIC_RESET_FATAL); in handle_login_rsp()
5549 ibmvnic_reset(adapter, VNIC_RESET_FATAL); in handle_login_rsp()
5553 size_array = (u64 *)((u8 *)(adapter->login_rsp_buf) + in handle_login_rsp()
5554 be32_to_cpu(adapter->login_rsp_buf->off_rxadd_buff_size)); in handle_login_rsp()
5558 adapter->cur_rx_buf_sz = be64_to_cpu(size_array[0]); in handle_login_rsp()
5560 num_tx_pools = be32_to_cpu(adapter->login_rsp_buf->num_txsubm_subcrqs); in handle_login_rsp()
5561 num_rx_pools = be32_to_cpu(adapter->login_rsp_buf->num_rxadd_subcrqs); in handle_login_rsp()
5563 tx_handle_array = (u64 *)((u8 *)(adapter->login_rsp_buf) + in handle_login_rsp()
5564 be32_to_cpu(adapter->login_rsp_buf->off_txsubm_subcrqs)); in handle_login_rsp()
5565 rx_handle_array = (u64 *)((u8 *)(adapter->login_rsp_buf) + in handle_login_rsp()
5566 be32_to_cpu(adapter->login_rsp_buf->off_rxadd_subcrqs)); in handle_login_rsp()
5569 adapter->tx_scrq[i]->handle = tx_handle_array[i]; in handle_login_rsp()
5572 adapter->rx_scrq[i]->handle = rx_handle_array[i]; in handle_login_rsp()
5574 adapter->num_active_tx_scrqs = num_tx_pools; in handle_login_rsp()
5575 adapter->num_active_rx_scrqs = num_rx_pools; in handle_login_rsp()
5576 release_login_rsp_buffer(adapter); in handle_login_rsp()
5577 release_login_buffer(adapter); in handle_login_rsp()
5578 complete(&adapter->init_done); in handle_login_rsp()
5584 struct ibmvnic_adapter *adapter) in handle_request_unmap_rsp() argument
5586 struct device *dev = &adapter->vdev->dev; in handle_request_unmap_rsp()
5595 struct ibmvnic_adapter *adapter) in handle_query_map_rsp() argument
5597 struct net_device *netdev = adapter->netdev; in handle_query_map_rsp()
5598 struct device *dev = &adapter->vdev->dev; in handle_query_map_rsp()
5613 struct ibmvnic_adapter *adapter) in handle_query_cap_rsp() argument
5615 struct net_device *netdev = adapter->netdev; in handle_query_cap_rsp()
5616 struct device *dev = &adapter->vdev->dev; in handle_query_cap_rsp()
5619 atomic_dec(&adapter->running_cap_crqs); in handle_query_cap_rsp()
5621 atomic_read(&adapter->running_cap_crqs)); in handle_query_cap_rsp()
5630 adapter->min_tx_queues = in handle_query_cap_rsp()
5633 adapter->min_tx_queues); in handle_query_cap_rsp()
5636 adapter->min_rx_queues = in handle_query_cap_rsp()
5639 adapter->min_rx_queues); in handle_query_cap_rsp()
5642 adapter->min_rx_add_queues = in handle_query_cap_rsp()
5645 adapter->min_rx_add_queues); in handle_query_cap_rsp()
5648 adapter->max_tx_queues = in handle_query_cap_rsp()
5651 adapter->max_tx_queues); in handle_query_cap_rsp()
5654 adapter->max_rx_queues = in handle_query_cap_rsp()
5657 adapter->max_rx_queues); in handle_query_cap_rsp()
5660 adapter->max_rx_add_queues = in handle_query_cap_rsp()
5663 adapter->max_rx_add_queues); in handle_query_cap_rsp()
5666 adapter->min_tx_entries_per_subcrq = in handle_query_cap_rsp()
5669 adapter->min_tx_entries_per_subcrq); in handle_query_cap_rsp()
5672 adapter->min_rx_add_entries_per_subcrq = in handle_query_cap_rsp()
5675 adapter->min_rx_add_entries_per_subcrq); in handle_query_cap_rsp()
5678 adapter->max_tx_entries_per_subcrq = in handle_query_cap_rsp()
5681 adapter->max_tx_entries_per_subcrq); in handle_query_cap_rsp()
5684 adapter->max_rx_add_entries_per_subcrq = in handle_query_cap_rsp()
5687 adapter->max_rx_add_entries_per_subcrq); in handle_query_cap_rsp()
5690 adapter->tcp_ip_offload = in handle_query_cap_rsp()
5693 adapter->tcp_ip_offload); in handle_query_cap_rsp()
5696 adapter->promisc_supported = in handle_query_cap_rsp()
5699 adapter->promisc_supported); in handle_query_cap_rsp()
5702 adapter->min_mtu = be64_to_cpu(crq->query_capability.number); in handle_query_cap_rsp()
5703 netdev->min_mtu = adapter->min_mtu - ETH_HLEN; in handle_query_cap_rsp()
5704 netdev_dbg(netdev, "min_mtu = %lld\n", adapter->min_mtu); in handle_query_cap_rsp()
5707 adapter->max_mtu = be64_to_cpu(crq->query_capability.number); in handle_query_cap_rsp()
5708 netdev->max_mtu = adapter->max_mtu - ETH_HLEN; in handle_query_cap_rsp()
5709 netdev_dbg(netdev, "max_mtu = %lld\n", adapter->max_mtu); in handle_query_cap_rsp()
5712 adapter->max_multicast_filters = in handle_query_cap_rsp()
5715 adapter->max_multicast_filters); in handle_query_cap_rsp()
5718 adapter->vlan_header_insertion = in handle_query_cap_rsp()
5720 if (adapter->vlan_header_insertion) in handle_query_cap_rsp()
5723 adapter->vlan_header_insertion); in handle_query_cap_rsp()
5726 adapter->rx_vlan_header_insertion = in handle_query_cap_rsp()
5729 adapter->rx_vlan_header_insertion); in handle_query_cap_rsp()
5732 adapter->max_tx_sg_entries = in handle_query_cap_rsp()
5735 adapter->max_tx_sg_entries); in handle_query_cap_rsp()
5738 adapter->rx_sg_supported = in handle_query_cap_rsp()
5741 adapter->rx_sg_supported); in handle_query_cap_rsp()
5744 adapter->opt_tx_comp_sub_queues = in handle_query_cap_rsp()
5747 adapter->opt_tx_comp_sub_queues); in handle_query_cap_rsp()
5750 adapter->opt_rx_comp_queues = in handle_query_cap_rsp()
5753 adapter->opt_rx_comp_queues); in handle_query_cap_rsp()
5756 adapter->opt_rx_bufadd_q_per_rx_comp_q = in handle_query_cap_rsp()
5759 adapter->opt_rx_bufadd_q_per_rx_comp_q); in handle_query_cap_rsp()
5762 adapter->opt_tx_entries_per_subcrq = in handle_query_cap_rsp()
5765 adapter->opt_tx_entries_per_subcrq); in handle_query_cap_rsp()
5768 adapter->opt_rxba_entries_per_subcrq = in handle_query_cap_rsp()
5771 adapter->opt_rxba_entries_per_subcrq); in handle_query_cap_rsp()
5774 adapter->tx_rx_desc_req = crq->query_capability.number; in handle_query_cap_rsp()
5776 adapter->tx_rx_desc_req); in handle_query_cap_rsp()
5785 if (atomic_read(&adapter->running_cap_crqs) == 0) in handle_query_cap_rsp()
5786 send_request_cap(adapter, 0); in handle_query_cap_rsp()
5789 static int send_query_phys_parms(struct ibmvnic_adapter *adapter) in send_query_phys_parms() argument
5798 mutex_lock(&adapter->fw_lock); in send_query_phys_parms()
5799 adapter->fw_done_rc = 0; in send_query_phys_parms()
5800 reinit_completion(&adapter->fw_done); in send_query_phys_parms()
5802 rc = ibmvnic_send_crq(adapter, &crq); in send_query_phys_parms()
5804 mutex_unlock(&adapter->fw_lock); in send_query_phys_parms()
5808 rc = ibmvnic_wait_for_completion(adapter, &adapter->fw_done, 10000); in send_query_phys_parms()
5810 mutex_unlock(&adapter->fw_lock); in send_query_phys_parms()
5814 mutex_unlock(&adapter->fw_lock); in send_query_phys_parms()
5815 return adapter->fw_done_rc ? -EIO : 0; in send_query_phys_parms()
5819 struct ibmvnic_adapter *adapter) in handle_query_phys_parms_rsp() argument
5821 struct net_device *netdev = adapter->netdev; in handle_query_phys_parms_rsp()
5832 adapter->speed = SPEED_10; in handle_query_phys_parms_rsp()
5835 adapter->speed = SPEED_100; in handle_query_phys_parms_rsp()
5838 adapter->speed = SPEED_1000; in handle_query_phys_parms_rsp()
5841 adapter->speed = SPEED_10000; in handle_query_phys_parms_rsp()
5844 adapter->speed = SPEED_25000; in handle_query_phys_parms_rsp()
5847 adapter->speed = SPEED_40000; in handle_query_phys_parms_rsp()
5850 adapter->speed = SPEED_50000; in handle_query_phys_parms_rsp()
5853 adapter->speed = SPEED_100000; in handle_query_phys_parms_rsp()
5856 adapter->speed = SPEED_200000; in handle_query_phys_parms_rsp()
5861 adapter->speed = SPEED_UNKNOWN; in handle_query_phys_parms_rsp()
5864 adapter->duplex = DUPLEX_FULL; in handle_query_phys_parms_rsp()
5866 adapter->duplex = DUPLEX_HALF; in handle_query_phys_parms_rsp()
5868 adapter->duplex = DUPLEX_UNKNOWN; in handle_query_phys_parms_rsp()
5874 struct ibmvnic_adapter *adapter) in ibmvnic_handle_crq() argument
5877 struct net_device *netdev = adapter->netdev; in ibmvnic_handle_crq()
5878 struct device *dev = &adapter->vdev->dev; in ibmvnic_handle_crq()
5890 adapter->from_passive_init = true; in ibmvnic_handle_crq()
5894 adapter->login_pending = false; in ibmvnic_handle_crq()
5896 if (adapter->state == VNIC_DOWN) in ibmvnic_handle_crq()
5897 rc = ibmvnic_reset(adapter, VNIC_RESET_PASSIVE_INIT); in ibmvnic_handle_crq()
5899 rc = ibmvnic_reset(adapter, VNIC_RESET_FAILOVER); in ibmvnic_handle_crq()
5903 * reset either because the adapter was still in ibmvnic_handle_crq()
5908 * is already scheduled or the adapter is in ibmvnic_handle_crq()
5914 adapter->failover_pending = false; in ibmvnic_handle_crq()
5917 if (!completion_done(&adapter->init_done)) { in ibmvnic_handle_crq()
5918 if (!adapter->init_done_rc) in ibmvnic_handle_crq()
5919 adapter->init_done_rc = -EAGAIN; in ibmvnic_handle_crq()
5920 complete(&adapter->init_done); in ibmvnic_handle_crq()
5926 adapter->crq.active = true; in ibmvnic_handle_crq()
5927 send_version_xchg(adapter); in ibmvnic_handle_crq()
5935 adapter->crq.active = false; in ibmvnic_handle_crq()
5939 if (!completion_done(&adapter->fw_done)) { in ibmvnic_handle_crq()
5940 adapter->fw_done_rc = -EIO; in ibmvnic_handle_crq()
5941 complete(&adapter->fw_done); in ibmvnic_handle_crq()
5945 if (!completion_done(&adapter->init_done)) { in ibmvnic_handle_crq()
5946 adapter->init_done_rc = -EAGAIN; in ibmvnic_handle_crq()
5947 complete(&adapter->init_done); in ibmvnic_handle_crq()
5950 if (!completion_done(&adapter->stats_done)) in ibmvnic_handle_crq()
5951 complete(&adapter->stats_done); in ibmvnic_handle_crq()
5952 if (test_bit(0, &adapter->resetting)) in ibmvnic_handle_crq()
5953 adapter->force_reset_recovery = true; in ibmvnic_handle_crq()
5955 dev_info(dev, "Migrated, re-enabling adapter\n"); in ibmvnic_handle_crq()
5956 ibmvnic_reset(adapter, VNIC_RESET_MOBILITY); in ibmvnic_handle_crq()
5959 adapter->failover_pending = true; in ibmvnic_handle_crq()
5961 /* The adapter lost the connection */ in ibmvnic_handle_crq()
5962 dev_err(dev, "Virtual Adapter failed (rc=%d)\n", in ibmvnic_handle_crq()
5964 ibmvnic_reset(adapter, VNIC_RESET_FATAL); in ibmvnic_handle_crq()
5986 send_query_cap(adapter); in ibmvnic_handle_crq()
5989 handle_query_cap_rsp(crq, adapter); in ibmvnic_handle_crq()
5992 handle_query_map_rsp(crq, adapter); in ibmvnic_handle_crq()
5995 adapter->fw_done_rc = crq->request_map_rsp.rc.code; in ibmvnic_handle_crq()
5996 complete(&adapter->fw_done); in ibmvnic_handle_crq()
5999 handle_request_unmap_rsp(crq, adapter); in ibmvnic_handle_crq()
6002 handle_request_cap_rsp(crq, adapter); in ibmvnic_handle_crq()
6006 handle_login_rsp(crq, adapter); in ibmvnic_handle_crq()
6013 adapter->logical_link_state = in ibmvnic_handle_crq()
6015 adapter->init_done_rc = crq->logical_link_state_rsp.rc.code; in ibmvnic_handle_crq()
6016 complete(&adapter->init_done); in ibmvnic_handle_crq()
6020 adapter->phys_link_state = in ibmvnic_handle_crq()
6022 adapter->logical_link_state = in ibmvnic_handle_crq()
6024 if (adapter->phys_link_state && adapter->logical_link_state) in ibmvnic_handle_crq()
6031 adapter->fw_done_rc = handle_change_mac_rsp(crq, adapter); in ibmvnic_handle_crq()
6035 handle_error_indication(crq, adapter); in ibmvnic_handle_crq()
6039 complete(&adapter->stats_done); in ibmvnic_handle_crq()
6043 handle_query_ip_offload_rsp(adapter); in ibmvnic_handle_crq()
6050 dma_unmap_single(dev, adapter->ip_offload_ctrl_tok, in ibmvnic_handle_crq()
6051 sizeof(adapter->ip_offload_ctrl), in ibmvnic_handle_crq()
6053 complete(&adapter->init_done); in ibmvnic_handle_crq()
6057 complete(&adapter->fw_done); in ibmvnic_handle_crq()
6060 handle_vpd_size_rsp(crq, adapter); in ibmvnic_handle_crq()
6063 handle_vpd_rsp(crq, adapter); in ibmvnic_handle_crq()
6066 adapter->fw_done_rc = handle_query_phys_parms_rsp(crq, adapter); in ibmvnic_handle_crq()
6067 complete(&adapter->fw_done); in ibmvnic_handle_crq()
6077 struct ibmvnic_adapter *adapter = instance; in ibmvnic_interrupt() local
6079 tasklet_schedule(&adapter->tasklet); in ibmvnic_interrupt()
6085 struct ibmvnic_adapter *adapter = from_tasklet(adapter, t, tasklet); in ibmvnic_tasklet() local
6086 struct ibmvnic_crq_queue *queue = &adapter->crq; in ibmvnic_tasklet()
6093 while ((crq = ibmvnic_next_crq(adapter)) != NULL) { in ibmvnic_tasklet()
6100 ibmvnic_handle_crq(crq, adapter); in ibmvnic_tasklet()
6107 static int ibmvnic_reenable_crq_queue(struct ibmvnic_adapter *adapter) in ibmvnic_reenable_crq_queue() argument
6109 struct vio_dev *vdev = adapter->vdev; in ibmvnic_reenable_crq_queue()
6117 dev_err(&vdev->dev, "Error enabling adapter (rc=%d)\n", rc); in ibmvnic_reenable_crq_queue()
6122 static int ibmvnic_reset_crq(struct ibmvnic_adapter *adapter) in ibmvnic_reset_crq() argument
6124 struct ibmvnic_crq_queue *crq = &adapter->crq; in ibmvnic_reset_crq()
6125 struct device *dev = &adapter->vdev->dev; in ibmvnic_reset_crq()
6126 struct vio_dev *vdev = adapter->vdev; in ibmvnic_reset_crq()
6147 /* Adapter is good, but other end is not ready */ in ibmvnic_reset_crq()
6148 dev_warn(dev, "Partner adapter not ready\n"); in ibmvnic_reset_crq()
6155 static void release_crq_queue(struct ibmvnic_adapter *adapter) in release_crq_queue() argument
6157 struct ibmvnic_crq_queue *crq = &adapter->crq; in release_crq_queue()
6158 struct vio_dev *vdev = adapter->vdev; in release_crq_queue()
6164 netdev_dbg(adapter->netdev, "Releasing CRQ\n"); in release_crq_queue()
6165 free_irq(vdev->irq, adapter); in release_crq_queue()
6166 tasklet_kill(&adapter->tasklet); in release_crq_queue()
6178 static int init_crq_queue(struct ibmvnic_adapter *adapter) in init_crq_queue() argument
6180 struct ibmvnic_crq_queue *crq = &adapter->crq; in init_crq_queue()
6181 struct device *dev = &adapter->vdev->dev; in init_crq_queue()
6182 struct vio_dev *vdev = adapter->vdev; in init_crq_queue()
6205 rc = ibmvnic_reset_crq(adapter); in init_crq_queue()
6209 dev_warn(dev, "Partner adapter not ready\n"); in init_crq_queue()
6211 dev_warn(dev, "Error %d opening adapter\n", rc); in init_crq_queue()
6217 tasklet_setup(&adapter->tasklet, (void *)ibmvnic_tasklet); in init_crq_queue()
6219 netdev_dbg(adapter->netdev, "registering irq 0x%x\n", vdev->irq); in init_crq_queue()
6221 adapter->vdev->unit_address); in init_crq_queue()
6222 rc = request_irq(vdev->irq, ibmvnic_interrupt, 0, crq->name, adapter); in init_crq_queue()
6239 tasklet_schedule(&adapter->tasklet); in init_crq_queue()
6244 tasklet_kill(&adapter->tasklet); in init_crq_queue()
6256 static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter, bool reset) in ibmvnic_reset_init() argument
6258 struct device *dev = &adapter->vdev->dev; in ibmvnic_reset_init()
6260 u64 old_num_rx_queues = adapter->req_rx_queues; in ibmvnic_reset_init()
6261 u64 old_num_tx_queues = adapter->req_tx_queues; in ibmvnic_reset_init()
6264 adapter->from_passive_init = false; in ibmvnic_reset_init()
6266 rc = ibmvnic_send_crq_init(adapter); in ibmvnic_reset_init()
6272 if (!wait_for_completion_timeout(&adapter->init_done, timeout)) { in ibmvnic_reset_init()
6277 if (adapter->init_done_rc) { in ibmvnic_reset_init()
6278 release_crq_queue(adapter); in ibmvnic_reset_init()
6279 dev_err(dev, "CRQ-init failed, %d\n", adapter->init_done_rc); in ibmvnic_reset_init()
6280 return adapter->init_done_rc; in ibmvnic_reset_init()
6283 if (adapter->from_passive_init) { in ibmvnic_reset_init()
6284 adapter->state = VNIC_OPEN; in ibmvnic_reset_init()
6285 adapter->from_passive_init = false; in ibmvnic_reset_init()
6291 test_bit(0, &adapter->resetting) && !adapter->wait_for_reset && in ibmvnic_reset_init()
6292 adapter->reset_reason != VNIC_RESET_MOBILITY) { in ibmvnic_reset_init()
6293 if (adapter->req_rx_queues != old_num_rx_queues || in ibmvnic_reset_init()
6294 adapter->req_tx_queues != old_num_tx_queues) { in ibmvnic_reset_init()
6295 release_sub_crqs(adapter, 0); in ibmvnic_reset_init()
6296 rc = init_sub_crqs(adapter); in ibmvnic_reset_init()
6305 clean_tx_pools(adapter); in ibmvnic_reset_init()
6307 rc = reset_sub_crq_queues(adapter); in ibmvnic_reset_init()
6310 rc = init_sub_crqs(adapter); in ibmvnic_reset_init()
6315 release_crq_queue(adapter); in ibmvnic_reset_init()
6319 rc = init_sub_crq_irqs(adapter); in ibmvnic_reset_init()
6322 release_crq_queue(adapter); in ibmvnic_reset_init()
6332 struct ibmvnic_adapter *adapter; in ibmvnic_probe() local
6356 adapter = netdev_priv(netdev); in ibmvnic_probe()
6357 adapter->state = VNIC_PROBING; in ibmvnic_probe()
6359 adapter->vdev = dev; in ibmvnic_probe()
6360 adapter->netdev = netdev; in ibmvnic_probe()
6361 adapter->login_pending = false; in ibmvnic_probe()
6362 memset(&adapter->map_ids, 0, sizeof(adapter->map_ids)); in ibmvnic_probe()
6364 bitmap_set(adapter->map_ids, 0, 1); in ibmvnic_probe()
6366 ether_addr_copy(adapter->mac_addr, mac_addr_p); in ibmvnic_probe()
6367 eth_hw_addr_set(netdev, adapter->mac_addr); in ibmvnic_probe()
6373 INIT_WORK(&adapter->ibmvnic_reset, __ibmvnic_reset); in ibmvnic_probe()
6374 INIT_DELAYED_WORK(&adapter->ibmvnic_delayed_reset, in ibmvnic_probe()
6376 INIT_LIST_HEAD(&adapter->rwi_list); in ibmvnic_probe()
6377 spin_lock_init(&adapter->rwi_lock); in ibmvnic_probe()
6378 spin_lock_init(&adapter->state_lock); in ibmvnic_probe()
6379 mutex_init(&adapter->fw_lock); in ibmvnic_probe()
6380 init_completion(&adapter->probe_done); in ibmvnic_probe()
6381 init_completion(&adapter->init_done); in ibmvnic_probe()
6382 init_completion(&adapter->fw_done); in ibmvnic_probe()
6383 init_completion(&adapter->reset_done); in ibmvnic_probe()
6384 init_completion(&adapter->stats_done); in ibmvnic_probe()
6385 clear_bit(0, &adapter->resetting); in ibmvnic_probe()
6386 adapter->prev_rx_buf_sz = 0; in ibmvnic_probe()
6387 adapter->prev_mtu = 0; in ibmvnic_probe()
6391 reinit_init_done(adapter); in ibmvnic_probe()
6396 adapter->failover_pending = false; in ibmvnic_probe()
6402 release_crq_queue(adapter); in ibmvnic_probe()
6414 spin_lock_irqsave(&adapter->rwi_lock, flags); in ibmvnic_probe()
6415 flush_reset_queue(adapter); in ibmvnic_probe()
6416 spin_unlock_irqrestore(&adapter->rwi_lock, flags); in ibmvnic_probe()
6418 rc = init_crq_queue(adapter); in ibmvnic_probe()
6425 rc = ibmvnic_reset_init(adapter, false); in ibmvnic_probe()
6436 rc = init_stats_buffers(adapter); in ibmvnic_probe()
6440 rc = init_stats_token(adapter); in ibmvnic_probe()
6451 adapter->state = VNIC_PROBED; in ibmvnic_probe()
6452 netdev->mtu = adapter->req_mtu - ETH_HLEN; in ibmvnic_probe()
6453 netdev->min_mtu = adapter->min_mtu - ETH_HLEN; in ibmvnic_probe()
6454 netdev->max_mtu = adapter->max_mtu - ETH_HLEN; in ibmvnic_probe()
6456 adapter->state = VNIC_DOWN; in ibmvnic_probe()
6459 adapter->wait_for_reset = false; in ibmvnic_probe()
6460 adapter->last_reset_time = jiffies; in ibmvnic_probe()
6469 rc = ibmvnic_cpu_notif_add(adapter); in ibmvnic_probe()
6475 complete(&adapter->probe_done); in ibmvnic_probe()
6486 release_stats_token(adapter); in ibmvnic_probe()
6489 release_stats_buffers(adapter); in ibmvnic_probe()
6492 release_sub_crqs(adapter, 1); in ibmvnic_probe()
6493 release_crq_queue(adapter); in ibmvnic_probe()
6498 adapter->state = VNIC_REMOVING; in ibmvnic_probe()
6499 complete(&adapter->probe_done); in ibmvnic_probe()
6500 flush_work(&adapter->ibmvnic_reset); in ibmvnic_probe()
6501 flush_delayed_work(&adapter->ibmvnic_delayed_reset); in ibmvnic_probe()
6503 flush_reset_queue(adapter); in ibmvnic_probe()
6505 mutex_destroy(&adapter->fw_lock); in ibmvnic_probe()
6514 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_remove() local
6517 spin_lock_irqsave(&adapter->state_lock, flags); in ibmvnic_remove()
6526 spin_lock(&adapter->rwi_lock); in ibmvnic_remove()
6527 adapter->state = VNIC_REMOVING; in ibmvnic_remove()
6528 spin_unlock(&adapter->rwi_lock); in ibmvnic_remove()
6530 spin_unlock_irqrestore(&adapter->state_lock, flags); in ibmvnic_remove()
6532 ibmvnic_cpu_notif_remove(adapter); in ibmvnic_remove()
6534 flush_work(&adapter->ibmvnic_reset); in ibmvnic_remove()
6535 flush_delayed_work(&adapter->ibmvnic_delayed_reset); in ibmvnic_remove()
6540 release_resources(adapter); in ibmvnic_remove()
6541 release_rx_pools(adapter); in ibmvnic_remove()
6542 release_tx_pools(adapter); in ibmvnic_remove()
6543 release_sub_crqs(adapter, 1); in ibmvnic_remove()
6544 release_crq_queue(adapter); in ibmvnic_remove()
6546 release_stats_token(adapter); in ibmvnic_remove()
6547 release_stats_buffers(adapter); in ibmvnic_remove()
6549 adapter->state = VNIC_REMOVED; in ibmvnic_remove()
6552 mutex_destroy(&adapter->fw_lock); in ibmvnic_remove()
6562 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in failover_store() local
6570 rc = plpar_hcall(H_VIOCTL, retbuf, adapter->vdev->unit_address, in failover_store()
6581 rc = plpar_hcall_norets(H_VIOCTL, adapter->vdev->unit_address, in failover_store()
6594 ibmvnic_reset(adapter, VNIC_RESET_FAILOVER); in failover_store()
6603 struct ibmvnic_adapter *adapter; in ibmvnic_get_desired_dma() local
6614 adapter = netdev_priv(netdev); in ibmvnic_get_desired_dma()
6619 for (i = 0; i < adapter->req_tx_queues + adapter->req_rx_queues; i++) in ibmvnic_get_desired_dma()
6622 for (i = 0; i < adapter->num_active_rx_pools; i++) in ibmvnic_get_desired_dma()
6623 ret += adapter->rx_pool[i].size * in ibmvnic_get_desired_dma()
6624 IOMMU_PAGE_ALIGN(adapter->rx_pool[i].buff_size, tbl); in ibmvnic_get_desired_dma()
6632 struct ibmvnic_adapter *adapter = netdev_priv(netdev); in ibmvnic_resume() local
6634 if (adapter->state != VNIC_OPEN) in ibmvnic_resume()
6637 tasklet_schedule(&adapter->tasklet); in ibmvnic_resume()