Lines Matching +full:icid +full:- +full:base
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
3 * Copyright (c) 2015-2017 QLogic Corporation
4 * Copyright (c) 2019-2020 Marvell International Ltd.
9 #include <linux/dma-mapping.h>
41 #define QED_LL2_RX_REGISTERED(ll2) ((ll2)->rx_queue.b_cb_registered)
42 #define QED_LL2_TX_REGISTERED(ll2) ((ll2)->tx_queue.b_cb_registered)
83 stats_id = MAX_NUM_LL2_RX_RAM_QUEUES + p_hwfn->abs_pf_id; in qed_ll2_handle_to_stats_id()
99 struct qed_dev *cdev = p_hwfn->cdev; in qed_ll2b_complete_tx_packet()
103 dma_unmap_single(&p_hwfn->cdev->pdev->dev, first_frag_addr, in qed_ll2b_complete_tx_packet()
106 if (cdev->ll2->cbs && cdev->ll2->cbs->tx_cb) in qed_ll2b_complete_tx_packet()
107 cdev->ll2->cbs->tx_cb(cdev->ll2->cb_cookie, skb, in qed_ll2b_complete_tx_packet()
116 size_t size = cdev->ll2->rx_size + NET_SKB_PAD + in qed_ll2_alloc_buffer()
122 return -ENOMEM; in qed_ll2_alloc_buffer()
125 *phys_addr = dma_map_single(&cdev->pdev->dev, in qed_ll2_alloc_buffer()
127 cdev->ll2->rx_size, DMA_FROM_DEVICE); in qed_ll2_alloc_buffer()
128 if (dma_mapping_error(&cdev->pdev->dev, *phys_addr)) { in qed_ll2_alloc_buffer()
131 return -ENOMEM; in qed_ll2_alloc_buffer()
140 spin_lock_bh(&cdev->ll2->lock); in qed_ll2_dealloc_buffer()
142 dma_unmap_single(&cdev->pdev->dev, buffer->phys_addr, in qed_ll2_dealloc_buffer()
143 cdev->ll2->rx_size, DMA_FROM_DEVICE); in qed_ll2_dealloc_buffer()
144 kfree(buffer->data); in qed_ll2_dealloc_buffer()
145 list_del(&buffer->list); in qed_ll2_dealloc_buffer()
147 cdev->ll2->rx_cnt--; in qed_ll2_dealloc_buffer()
148 if (!cdev->ll2->rx_cnt) in qed_ll2_dealloc_buffer()
151 spin_unlock_bh(&cdev->ll2->lock); in qed_ll2_dealloc_buffer()
160 list_for_each_entry_safe(buffer, tmp_buffer, &cdev->ll2->list, list) in qed_ll2_kill_buffers()
168 struct qed_ll2_buffer *buffer = data->cookie; in qed_ll2b_complete_rx_packet()
169 struct qed_dev *cdev = p_hwfn->cdev; in qed_ll2b_complete_rx_packet()
173 int rc = -EINVAL; in qed_ll2b_complete_rx_packet()
179 (u64)data->rx_buf_addr, in qed_ll2b_complete_rx_packet()
180 data->u.placement_offset, in qed_ll2b_complete_rx_packet()
181 data->length.packet_length, in qed_ll2b_complete_rx_packet()
182 data->parse_flags, in qed_ll2b_complete_rx_packet()
183 data->vlan, data->opaque_data_0, data->opaque_data_1); in qed_ll2b_complete_rx_packet()
185 if ((cdev->dp_module & NETIF_MSG_PKTDATA) && buffer->data) { in qed_ll2b_complete_rx_packet()
188 buffer->data, data->length.packet_length, false); in qed_ll2b_complete_rx_packet()
192 if (data->length.packet_length < ETH_HLEN) in qed_ll2b_complete_rx_packet()
197 rc = qed_ll2_alloc_buffer(p_hwfn->cdev, &new_data, in qed_ll2b_complete_rx_packet()
203 dma_unmap_single(&cdev->pdev->dev, buffer->phys_addr, in qed_ll2b_complete_rx_packet()
204 cdev->ll2->rx_size, DMA_FROM_DEVICE); in qed_ll2b_complete_rx_packet()
206 skb = slab_build_skb(buffer->data); in qed_ll2b_complete_rx_packet()
209 kfree(buffer->data); in qed_ll2b_complete_rx_packet()
213 data->u.placement_offset += NET_SKB_PAD; in qed_ll2b_complete_rx_packet()
214 skb_reserve(skb, data->u.placement_offset); in qed_ll2b_complete_rx_packet()
215 skb_put(skb, data->length.packet_length); in qed_ll2b_complete_rx_packet()
222 skb->protocol = eth_hdr(skb)->h_proto; in qed_ll2b_complete_rx_packet()
225 if (cdev->ll2->cbs && cdev->ll2->cbs->rx_cb) { in qed_ll2b_complete_rx_packet()
226 if (data->vlan) in qed_ll2b_complete_rx_packet()
228 data->vlan); in qed_ll2b_complete_rx_packet()
229 cdev->ll2->cbs->rx_cb(cdev->ll2->cb_cookie, skb, in qed_ll2b_complete_rx_packet()
230 data->opaque_data_0, in qed_ll2b_complete_rx_packet()
231 data->opaque_data_1); in qed_ll2b_complete_rx_packet()
236 kfree(buffer->data); in qed_ll2b_complete_rx_packet()
241 buffer->data = new_data; in qed_ll2b_complete_rx_packet()
242 buffer->phys_addr = new_phys_addr; in qed_ll2b_complete_rx_packet()
245 rc = qed_ll2_post_rx_buffer(p_hwfn, cdev->ll2->handle, in qed_ll2b_complete_rx_packet()
246 buffer->phys_addr, 0, buffer, 1); in qed_ll2b_complete_rx_packet()
261 if (!p_hwfn->p_ll2_info) in __qed_ll2_handle_sanity()
264 p_ll2_conn = &p_hwfn->p_ll2_info[connection_handle]; in __qed_ll2_handle_sanity()
268 mutex_lock(&p_ll2_conn->mutex); in __qed_ll2_handle_sanity()
269 if (p_ll2_conn->b_active) in __qed_ll2_handle_sanity()
272 mutex_unlock(&p_ll2_conn->mutex); in __qed_ll2_handle_sanity()
312 p_tx = &p_ll2_conn->tx_queue; in qed_ll2_txq_flush()
314 spin_lock_irqsave(&p_tx->lock, flags); in qed_ll2_txq_flush()
315 while (!list_empty(&p_tx->active_descq)) { in qed_ll2_txq_flush()
316 p_pkt = list_first_entry(&p_tx->active_descq, in qed_ll2_txq_flush()
321 list_del(&p_pkt->list_entry); in qed_ll2_txq_flush()
322 b_last_packet = list_empty(&p_tx->active_descq); in qed_ll2_txq_flush()
323 list_add_tail(&p_pkt->list_entry, &p_tx->free_descq); in qed_ll2_txq_flush()
324 spin_unlock_irqrestore(&p_tx->lock, flags); in qed_ll2_txq_flush()
325 if (p_ll2_conn->input.conn_type == QED_LL2_TYPE_OOO) { in qed_ll2_txq_flush()
328 p_buffer = (struct qed_ooo_buffer *)p_pkt->cookie; in qed_ll2_txq_flush()
329 qed_ooo_put_free_buffer(p_hwfn, p_hwfn->p_ooo_info, in qed_ll2_txq_flush()
332 p_tx->cur_completing_packet = *p_pkt; in qed_ll2_txq_flush()
333 p_tx->cur_completing_bd_idx = 1; in qed_ll2_txq_flush()
335 p_tx->cur_completing_bd_idx == p_pkt->bd_used; in qed_ll2_txq_flush()
336 tx_frag = p_pkt->bds_set[0].tx_frag; in qed_ll2_txq_flush()
337 p_ll2_conn->cbs.tx_release_cb(p_ll2_conn->cbs.cookie, in qed_ll2_txq_flush()
338 p_ll2_conn->my_id, in qed_ll2_txq_flush()
339 p_pkt->cookie, in qed_ll2_txq_flush()
344 spin_lock_irqsave(&p_tx->lock, flags); in qed_ll2_txq_flush()
346 spin_unlock_irqrestore(&p_tx->lock, flags); in qed_ll2_txq_flush()
352 struct qed_ll2_tx_queue *p_tx = &p_ll2_conn->tx_queue; in qed_ll2_txq_completion()
357 int rc = -EINVAL; in qed_ll2_txq_completion()
362 spin_lock_irqsave(&p_tx->lock, flags); in qed_ll2_txq_completion()
363 if (p_tx->b_completing_packet) { in qed_ll2_txq_completion()
364 rc = -EBUSY; in qed_ll2_txq_completion()
368 new_idx = le16_to_cpu(*p_tx->p_fw_cons); in qed_ll2_txq_completion()
369 num_bds = ((s16)new_idx - (s16)p_tx->bds_idx); in qed_ll2_txq_completion()
371 if (list_empty(&p_tx->active_descq)) in qed_ll2_txq_completion()
374 p_pkt = list_first_entry(&p_tx->active_descq, in qed_ll2_txq_completion()
379 p_tx->b_completing_packet = true; in qed_ll2_txq_completion()
380 p_tx->cur_completing_packet = *p_pkt; in qed_ll2_txq_completion()
381 num_bds_in_packet = p_pkt->bd_used; in qed_ll2_txq_completion()
382 list_del(&p_pkt->list_entry); in qed_ll2_txq_completion()
390 num_bds -= num_bds_in_packet; in qed_ll2_txq_completion()
391 p_tx->bds_idx += num_bds_in_packet; in qed_ll2_txq_completion()
392 while (num_bds_in_packet--) in qed_ll2_txq_completion()
393 qed_chain_consume(&p_tx->txq_chain); in qed_ll2_txq_completion()
395 p_tx->cur_completing_bd_idx = 1; in qed_ll2_txq_completion()
396 b_last_frag = p_tx->cur_completing_bd_idx == p_pkt->bd_used; in qed_ll2_txq_completion()
397 list_add_tail(&p_pkt->list_entry, &p_tx->free_descq); in qed_ll2_txq_completion()
399 spin_unlock_irqrestore(&p_tx->lock, flags); in qed_ll2_txq_completion()
401 p_ll2_conn->cbs.tx_comp_cb(p_ll2_conn->cbs.cookie, in qed_ll2_txq_completion()
402 p_ll2_conn->my_id, in qed_ll2_txq_completion()
403 p_pkt->cookie, in qed_ll2_txq_completion()
404 p_pkt->bds_set[0].tx_frag, in qed_ll2_txq_completion()
407 spin_lock_irqsave(&p_tx->lock, flags); in qed_ll2_txq_completion()
410 p_tx->b_completing_packet = false; in qed_ll2_txq_completion()
413 spin_unlock_irqrestore(&p_tx->lock, flags); in qed_ll2_txq_completion()
421 data->parse_flags = le16_to_cpu(p_cqe->rx_cqe_gsi.parse_flags.flags); in qed_ll2_rxq_parse_gsi()
422 data->length.data_length = le16_to_cpu(p_cqe->rx_cqe_gsi.data_length); in qed_ll2_rxq_parse_gsi()
423 data->vlan = le16_to_cpu(p_cqe->rx_cqe_gsi.vlan); in qed_ll2_rxq_parse_gsi()
424 data->opaque_data_0 = le32_to_cpu(p_cqe->rx_cqe_gsi.src_mac_addrhi); in qed_ll2_rxq_parse_gsi()
425 data->opaque_data_1 = le16_to_cpu(p_cqe->rx_cqe_gsi.src_mac_addrlo); in qed_ll2_rxq_parse_gsi()
426 data->u.data_length_error = p_cqe->rx_cqe_gsi.data_length_error; in qed_ll2_rxq_parse_gsi()
427 data->qp_id = le16_to_cpu(p_cqe->rx_cqe_gsi.qp_id); in qed_ll2_rxq_parse_gsi()
429 data->src_qp = le32_to_cpu(p_cqe->rx_cqe_gsi.src_qp); in qed_ll2_rxq_parse_gsi()
436 data->parse_flags = le16_to_cpu(p_cqe->rx_cqe_fp.parse_flags.flags); in qed_ll2_rxq_parse_reg()
437 data->err_flags = le16_to_cpu(p_cqe->rx_cqe_fp.err_flags.flags); in qed_ll2_rxq_parse_reg()
438 data->length.packet_length = in qed_ll2_rxq_parse_reg()
439 le16_to_cpu(p_cqe->rx_cqe_fp.packet_length); in qed_ll2_rxq_parse_reg()
440 data->vlan = le16_to_cpu(p_cqe->rx_cqe_fp.vlan); in qed_ll2_rxq_parse_reg()
441 data->opaque_data_0 = le32_to_cpu(p_cqe->rx_cqe_fp.opaque_data.data[0]); in qed_ll2_rxq_parse_reg()
442 data->opaque_data_1 = le32_to_cpu(p_cqe->rx_cqe_fp.opaque_data.data[1]); in qed_ll2_rxq_parse_reg()
443 data->u.placement_offset = p_cqe->rx_cqe_fp.placement_offset; in qed_ll2_rxq_parse_reg()
452 struct qed_ll2_rx_queue *p_rx = &p_ll2_conn->rx_queue; in qed_ll2_handle_slowpath()
455 sp_cqe = &p_cqe->rx_cqe_sp; in qed_ll2_handle_slowpath()
456 if (sp_cqe->ramrod_cmd_id != CORE_RAMROD_RX_QUEUE_FLUSH) { in qed_ll2_handle_slowpath()
458 "LL2 - unexpected Rx CQE slowpath ramrod_cmd_id:%d\n", in qed_ll2_handle_slowpath()
459 sp_cqe->ramrod_cmd_id); in qed_ll2_handle_slowpath()
460 return -EINVAL; in qed_ll2_handle_slowpath()
463 if (!p_ll2_conn->cbs.slowpath_cb) { in qed_ll2_handle_slowpath()
465 "LL2 - received RX_QUEUE_FLUSH but no callback was provided\n"); in qed_ll2_handle_slowpath()
466 return -EINVAL; in qed_ll2_handle_slowpath()
469 spin_unlock_irqrestore(&p_rx->lock, *p_lock_flags); in qed_ll2_handle_slowpath()
471 p_ll2_conn->cbs.slowpath_cb(p_ll2_conn->cbs.cookie, in qed_ll2_handle_slowpath()
472 p_ll2_conn->my_id, in qed_ll2_handle_slowpath()
473 le32_to_cpu(sp_cqe->opaque_data.data[0]), in qed_ll2_handle_slowpath()
474 le32_to_cpu(sp_cqe->opaque_data.data[1])); in qed_ll2_handle_slowpath()
476 spin_lock_irqsave(&p_rx->lock, *p_lock_flags); in qed_ll2_handle_slowpath()
487 struct qed_ll2_rx_queue *p_rx = &p_ll2_conn->rx_queue; in qed_ll2_rxq_handle_completion()
491 if (!list_empty(&p_rx->active_descq)) in qed_ll2_rxq_handle_completion()
492 p_pkt = list_first_entry(&p_rx->active_descq, in qed_ll2_rxq_handle_completion()
497 p_ll2_conn->input.conn_type); in qed_ll2_rxq_handle_completion()
499 return -EIO; in qed_ll2_rxq_handle_completion()
501 list_del(&p_pkt->list_entry); in qed_ll2_rxq_handle_completion()
503 if (p_cqe->rx_cqe_sp.type == CORE_RX_CQE_TYPE_REGULAR) in qed_ll2_rxq_handle_completion()
507 if (unlikely(qed_chain_consume(&p_rx->rxq_chain) != p_pkt->rxq_bd)) in qed_ll2_rxq_handle_completion()
511 list_add_tail(&p_pkt->list_entry, &p_rx->free_descq); in qed_ll2_rxq_handle_completion()
513 data.connection_handle = p_ll2_conn->my_id; in qed_ll2_rxq_handle_completion()
514 data.cookie = p_pkt->cookie; in qed_ll2_rxq_handle_completion()
515 data.rx_buf_addr = p_pkt->rx_buf_addr; in qed_ll2_rxq_handle_completion()
518 spin_unlock_irqrestore(&p_rx->lock, *p_lock_flags); in qed_ll2_rxq_handle_completion()
519 p_ll2_conn->cbs.rx_comp_cb(p_ll2_conn->cbs.cookie, &data); in qed_ll2_rxq_handle_completion()
521 spin_lock_irqsave(&p_rx->lock, *p_lock_flags); in qed_ll2_rxq_handle_completion()
529 struct qed_ll2_rx_queue *p_rx = &p_ll2_conn->rx_queue; in qed_ll2_rxq_completion()
538 spin_lock_irqsave(&p_rx->lock, flags); in qed_ll2_rxq_completion()
541 spin_unlock_irqrestore(&p_rx->lock, flags); in qed_ll2_rxq_completion()
545 cq_new_idx = le16_to_cpu(*p_rx->p_fw_cons); in qed_ll2_rxq_completion()
546 cq_old_idx = qed_chain_get_cons_idx(&p_rx->rcq_chain); in qed_ll2_rxq_completion()
553 qed_chain_consume(&p_rx->rcq_chain); in qed_ll2_rxq_completion()
554 cq_old_idx = qed_chain_get_cons_idx(&p_rx->rcq_chain); in qed_ll2_rxq_completion()
558 "LL2 [sw. cons %04x, fw. at %04x] - Got Packet of type %02x\n", in qed_ll2_rxq_completion()
559 cq_old_idx, cq_new_idx, cqe->rx_cqe_sp.type); in qed_ll2_rxq_completion()
561 switch (cqe->rx_cqe_sp.type) { in qed_ll2_rxq_completion()
573 rc = -EIO; in qed_ll2_rxq_completion()
577 spin_unlock_irqrestore(&p_rx->lock, flags); in qed_ll2_rxq_completion()
592 p_rx = &p_ll2_conn->rx_queue; in qed_ll2_rxq_flush()
594 spin_lock_irqsave(&p_rx->lock, flags); in qed_ll2_rxq_flush()
595 while (!list_empty(&p_rx->active_descq)) { in qed_ll2_rxq_flush()
596 p_pkt = list_first_entry(&p_rx->active_descq, in qed_ll2_rxq_flush()
600 list_move_tail(&p_pkt->list_entry, &p_rx->free_descq); in qed_ll2_rxq_flush()
601 spin_unlock_irqrestore(&p_rx->lock, flags); in qed_ll2_rxq_flush()
603 if (p_ll2_conn->input.conn_type == QED_LL2_TYPE_OOO) { in qed_ll2_rxq_flush()
606 p_buffer = (struct qed_ooo_buffer *)p_pkt->cookie; in qed_ll2_rxq_flush()
607 qed_ooo_put_free_buffer(p_hwfn, p_hwfn->p_ooo_info, in qed_ll2_rxq_flush()
610 dma_addr_t rx_buf_addr = p_pkt->rx_buf_addr; in qed_ll2_rxq_flush()
611 void *cookie = p_pkt->cookie; in qed_ll2_rxq_flush()
614 b_last = list_empty(&p_rx->active_descq); in qed_ll2_rxq_flush()
615 p_ll2_conn->cbs.rx_release_cb(p_ll2_conn->cbs.cookie, in qed_ll2_rxq_flush()
616 p_ll2_conn->my_id, in qed_ll2_rxq_flush()
620 spin_lock_irqsave(&p_rx->lock, flags); in qed_ll2_rxq_flush()
622 spin_unlock_irqrestore(&p_rx->lock, flags); in qed_ll2_rxq_flush()
632 if (p_cqe->ramrod_cmd_id != CORE_RAMROD_RX_QUEUE_FLUSH) in qed_ll2_lb_rxq_handler_slowpath()
635 ooo_opq = (struct ooo_opaque *)&p_cqe->opaque_data; in qed_ll2_lb_rxq_handler_slowpath()
636 if (ooo_opq->ooo_opcode != TCP_EVENT_DELETE_ISLES) in qed_ll2_lb_rxq_handler_slowpath()
640 cid = le32_to_cpu(ooo_opq->cid); in qed_ll2_lb_rxq_handler_slowpath()
641 qed_ooo_release_connection_isles(p_hwfn, p_hwfn->p_ooo_info, cid); in qed_ll2_lb_rxq_handler_slowpath()
649 struct qed_ll2_rx_queue *p_rx = &p_ll2_conn->rx_queue; in qed_ll2_lb_rxq_handler()
660 cq_new_idx = le16_to_cpu(*p_rx->p_fw_cons); in qed_ll2_lb_rxq_handler()
661 cq_old_idx = qed_chain_get_cons_idx(&p_rx->rcq_chain); in qed_ll2_lb_rxq_handler()
668 cqe = qed_chain_consume(&p_rx->rcq_chain); in qed_ll2_lb_rxq_handler()
669 cq_old_idx = qed_chain_get_cons_idx(&p_rx->rcq_chain); in qed_ll2_lb_rxq_handler()
670 cqe_type = cqe->rx_cqe_sp.type; in qed_ll2_lb_rxq_handler()
674 &cqe->rx_cqe_sp)) in qed_ll2_lb_rxq_handler()
679 "Got a non-regular LB LL2 completion [type 0x%02x]\n", in qed_ll2_lb_rxq_handler()
681 return -EINVAL; in qed_ll2_lb_rxq_handler()
683 p_cqe_fp = &cqe->rx_cqe_fp; in qed_ll2_lb_rxq_handler()
685 placement_offset = p_cqe_fp->placement_offset; in qed_ll2_lb_rxq_handler()
686 parse_flags = le16_to_cpu(p_cqe_fp->parse_flags.flags); in qed_ll2_lb_rxq_handler()
687 packet_length = le16_to_cpu(p_cqe_fp->packet_length); in qed_ll2_lb_rxq_handler()
688 vlan = le16_to_cpu(p_cqe_fp->vlan); in qed_ll2_lb_rxq_handler()
689 ooo_opq = (struct ooo_opaque *)&p_cqe_fp->opaque_data; in qed_ll2_lb_rxq_handler()
690 qed_ooo_save_history_entry(p_hwfn, p_hwfn->p_ooo_info, ooo_opq); in qed_ll2_lb_rxq_handler()
691 cid = le32_to_cpu(ooo_opq->cid); in qed_ll2_lb_rxq_handler()
694 if (ooo_opq->drop_size) in qed_ll2_lb_rxq_handler()
695 qed_ooo_delete_isles(p_hwfn, p_hwfn->p_ooo_info, cid, in qed_ll2_lb_rxq_handler()
696 ooo_opq->drop_isle, in qed_ll2_lb_rxq_handler()
697 ooo_opq->drop_size); in qed_ll2_lb_rxq_handler()
699 if (ooo_opq->ooo_opcode == TCP_EVENT_NOP) in qed_ll2_lb_rxq_handler()
703 if (unlikely(list_empty(&p_rx->active_descq))) { in qed_ll2_lb_rxq_handler()
707 return -EIO; in qed_ll2_lb_rxq_handler()
710 p_pkt = list_first_entry(&p_rx->active_descq, in qed_ll2_lb_rxq_handler()
713 if (likely(ooo_opq->ooo_opcode == TCP_EVENT_ADD_NEW_ISLE || in qed_ll2_lb_rxq_handler()
714 ooo_opq->ooo_opcode == TCP_EVENT_ADD_ISLE_RIGHT || in qed_ll2_lb_rxq_handler()
715 ooo_opq->ooo_opcode == TCP_EVENT_ADD_ISLE_LEFT || in qed_ll2_lb_rxq_handler()
716 ooo_opq->ooo_opcode == TCP_EVENT_ADD_PEN || in qed_ll2_lb_rxq_handler()
717 ooo_opq->ooo_opcode == TCP_EVENT_JOIN)) { in qed_ll2_lb_rxq_handler()
721 return -EIO; in qed_ll2_lb_rxq_handler()
723 list_del(&p_pkt->list_entry); in qed_ll2_lb_rxq_handler()
724 p_buffer = (struct qed_ooo_buffer *)p_pkt->cookie; in qed_ll2_lb_rxq_handler()
725 p_buffer->packet_length = packet_length; in qed_ll2_lb_rxq_handler()
726 p_buffer->parse_flags = parse_flags; in qed_ll2_lb_rxq_handler()
727 p_buffer->vlan = vlan; in qed_ll2_lb_rxq_handler()
728 p_buffer->placement_offset = placement_offset; in qed_ll2_lb_rxq_handler()
729 qed_chain_consume(&p_rx->rxq_chain); in qed_ll2_lb_rxq_handler()
730 list_add_tail(&p_pkt->list_entry, &p_rx->free_descq); in qed_ll2_lb_rxq_handler()
732 switch (ooo_opq->ooo_opcode) { in qed_ll2_lb_rxq_handler()
735 p_hwfn->p_ooo_info, in qed_ll2_lb_rxq_handler()
737 ooo_opq->ooo_isle, in qed_ll2_lb_rxq_handler()
742 p_hwfn->p_ooo_info, in qed_ll2_lb_rxq_handler()
744 ooo_opq->ooo_isle, in qed_ll2_lb_rxq_handler()
750 p_hwfn->p_ooo_info, in qed_ll2_lb_rxq_handler()
752 ooo_opq->ooo_isle, in qed_ll2_lb_rxq_handler()
758 p_hwfn->p_ooo_info, in qed_ll2_lb_rxq_handler()
760 ooo_opq->ooo_isle + 1, in qed_ll2_lb_rxq_handler()
764 p_hwfn->p_ooo_info, in qed_ll2_lb_rxq_handler()
765 cid, ooo_opq->ooo_isle); in qed_ll2_lb_rxq_handler()
769 p_hwfn->p_ooo_info, in qed_ll2_lb_rxq_handler()
776 ooo_opq->ooo_opcode); in qed_ll2_lb_rxq_handler()
796 p_hwfn->p_ooo_info))) { in qed_ooo_submit_tx_buffers()
800 first_frag = p_buffer->rx_buffer_phys_addr + in qed_ooo_submit_tx_buffers()
801 p_buffer->placement_offset; in qed_ooo_submit_tx_buffers()
807 tx_pkt.vlan = p_buffer->vlan; in qed_ooo_submit_tx_buffers()
810 switch (p_ll2_conn->tx_dest) { in qed_ooo_submit_tx_buffers()
823 tx_pkt.first_frag_len = p_buffer->packet_length; in qed_ooo_submit_tx_buffers()
826 rc = qed_ll2_prepare_tx_packet(p_hwfn, p_ll2_conn->my_id, in qed_ooo_submit_tx_buffers()
829 qed_ooo_put_ready_buffer(p_hwfn, p_hwfn->p_ooo_info, in qed_ooo_submit_tx_buffers()
844 p_hwfn->p_ooo_info))) { in qed_ooo_submit_rx_buffers()
846 p_ll2_conn->my_id, in qed_ooo_submit_rx_buffers()
847 p_buffer->rx_buffer_phys_addr, in qed_ooo_submit_rx_buffers()
851 p_hwfn->p_ooo_info, p_buffer); in qed_ooo_submit_rx_buffers()
881 struct qed_ll2_tx_queue *p_tx = &p_ll2_conn->tx_queue; in qed_ll2_lb_txq_completion()
894 new_idx = le16_to_cpu(*p_tx->p_fw_cons); in qed_ll2_lb_txq_completion()
895 num_bds = ((s16)new_idx - (s16)p_tx->bds_idx); in qed_ll2_lb_txq_completion()
901 if (list_empty(&p_tx->active_descq)) in qed_ll2_lb_txq_completion()
902 return -EINVAL; in qed_ll2_lb_txq_completion()
904 p_pkt = list_first_entry(&p_tx->active_descq, in qed_ll2_lb_txq_completion()
907 return -EINVAL; in qed_ll2_lb_txq_completion()
909 if (unlikely(p_pkt->bd_used != 1)) { in qed_ll2_lb_txq_completion()
912 p_pkt->bd_used); in qed_ll2_lb_txq_completion()
913 return -EINVAL; in qed_ll2_lb_txq_completion()
916 list_del(&p_pkt->list_entry); in qed_ll2_lb_txq_completion()
918 num_bds--; in qed_ll2_lb_txq_completion()
919 p_tx->bds_idx++; in qed_ll2_lb_txq_completion()
920 qed_chain_consume(&p_tx->txq_chain); in qed_ll2_lb_txq_completion()
922 p_buffer = (struct qed_ooo_buffer *)p_pkt->cookie; in qed_ll2_lb_txq_completion()
923 list_add_tail(&p_pkt->list_entry, &p_tx->free_descq); in qed_ll2_lb_txq_completion()
926 qed_ooo_put_free_buffer(p_hwfn, p_hwfn->p_ooo_info, in qed_ll2_lb_txq_completion()
931 rc = qed_ll2_post_rx_buffer(p_hwfn, p_ll2_conn->my_id, in qed_ll2_lb_txq_completion()
932 p_buffer->rx_buffer_phys_addr, 0, in qed_ll2_lb_txq_completion()
936 p_hwfn->p_ooo_info, p_buffer); in qed_ll2_lb_txq_completion()
948 u8 *handle = &p_hwfn->pf_params.iscsi_pf_params.ll2_ooo_queue_id; in qed_ll2_stop_ooo()
962 enum qed_ll2_conn_type conn_type = p_ll2_conn->input.conn_type; in qed_sp_ll2_rx_queue_start()
963 struct qed_ll2_rx_queue *p_rx = &p_ll2_conn->rx_queue; in qed_sp_ll2_rx_queue_start()
972 init_data.cid = p_ll2_conn->cid; in qed_sp_ll2_rx_queue_start()
973 init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_sp_ll2_rx_queue_start()
982 p_ramrod = &p_ent->ramrod.core_rx_queue_start; in qed_sp_ll2_rx_queue_start()
984 p_ramrod->sb_id = cpu_to_le16(qed_int_get_sp_sb_id(p_hwfn)); in qed_sp_ll2_rx_queue_start()
985 p_ramrod->sb_index = p_rx->rx_sb_index; in qed_sp_ll2_rx_queue_start()
986 p_ramrod->complete_event_flg = 1; in qed_sp_ll2_rx_queue_start()
988 p_ramrod->mtu = cpu_to_le16(p_ll2_conn->input.mtu); in qed_sp_ll2_rx_queue_start()
989 DMA_REGPAIR_LE(p_ramrod->bd_base, p_rx->rxq_chain.p_phys_addr); in qed_sp_ll2_rx_queue_start()
990 cqe_pbl_size = (u16)qed_chain_get_page_cnt(&p_rx->rcq_chain); in qed_sp_ll2_rx_queue_start()
991 p_ramrod->num_of_pbl_pages = cpu_to_le16(cqe_pbl_size); in qed_sp_ll2_rx_queue_start()
992 DMA_REGPAIR_LE(p_ramrod->cqe_pbl_addr, in qed_sp_ll2_rx_queue_start()
993 qed_chain_get_pbl_phys(&p_rx->rcq_chain)); in qed_sp_ll2_rx_queue_start()
995 p_ramrod->drop_ttl0_flg = p_ll2_conn->input.rx_drop_ttl0_flg; in qed_sp_ll2_rx_queue_start()
996 p_ramrod->inner_vlan_stripping_en = in qed_sp_ll2_rx_queue_start()
997 p_ll2_conn->input.rx_vlan_removal_en; in qed_sp_ll2_rx_queue_start()
999 if (test_bit(QED_MF_UFP_SPECIFIC, &p_hwfn->cdev->mf_bits) && in qed_sp_ll2_rx_queue_start()
1000 p_ll2_conn->input.conn_type == QED_LL2_TYPE_FCOE) in qed_sp_ll2_rx_queue_start()
1001 p_ramrod->report_outer_vlan = 1; in qed_sp_ll2_rx_queue_start()
1002 p_ramrod->queue_id = p_ll2_conn->queue_id; in qed_sp_ll2_rx_queue_start()
1003 p_ramrod->main_func_queue = p_ll2_conn->main_func_queue ? 1 : 0; in qed_sp_ll2_rx_queue_start()
1005 if (test_bit(QED_MF_LL2_NON_UNICAST, &p_hwfn->cdev->mf_bits) && in qed_sp_ll2_rx_queue_start()
1006 p_ramrod->main_func_queue && conn_type != QED_LL2_TYPE_ROCE && in qed_sp_ll2_rx_queue_start()
1009 p_ramrod->mf_si_bcast_accept_all = 1; in qed_sp_ll2_rx_queue_start()
1010 p_ramrod->mf_si_mcast_accept_all = 1; in qed_sp_ll2_rx_queue_start()
1012 p_ramrod->mf_si_bcast_accept_all = 0; in qed_sp_ll2_rx_queue_start()
1013 p_ramrod->mf_si_mcast_accept_all = 0; in qed_sp_ll2_rx_queue_start()
1016 p_ramrod->action_on_error.error_type = action_on_error; in qed_sp_ll2_rx_queue_start()
1017 p_ramrod->gsi_offload_flag = p_ll2_conn->input.gsi_enable; in qed_sp_ll2_rx_queue_start()
1018 p_ramrod->zero_prod_flg = 1; in qed_sp_ll2_rx_queue_start()
1026 enum qed_ll2_conn_type conn_type = p_ll2_conn->input.conn_type; in qed_sp_ll2_tx_queue_start()
1027 struct qed_ll2_tx_queue *p_tx = &p_ll2_conn->tx_queue; in qed_sp_ll2_tx_queue_start()
1032 int rc = -EINVAL; in qed_sp_ll2_tx_queue_start()
1037 if (likely(p_ll2_conn->input.conn_type == QED_LL2_TYPE_OOO)) in qed_sp_ll2_tx_queue_start()
1038 p_ll2_conn->tx_stats_en = 0; in qed_sp_ll2_tx_queue_start()
1040 p_ll2_conn->tx_stats_en = 1; in qed_sp_ll2_tx_queue_start()
1044 init_data.cid = p_ll2_conn->cid; in qed_sp_ll2_tx_queue_start()
1045 init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_sp_ll2_tx_queue_start()
1054 p_ramrod = &p_ent->ramrod.core_tx_queue_start; in qed_sp_ll2_tx_queue_start()
1056 p_ramrod->sb_id = cpu_to_le16(qed_int_get_sp_sb_id(p_hwfn)); in qed_sp_ll2_tx_queue_start()
1057 p_ramrod->sb_index = p_tx->tx_sb_index; in qed_sp_ll2_tx_queue_start()
1058 p_ramrod->mtu = cpu_to_le16(p_ll2_conn->input.mtu); in qed_sp_ll2_tx_queue_start()
1059 p_ramrod->stats_en = p_ll2_conn->tx_stats_en; in qed_sp_ll2_tx_queue_start()
1060 p_ramrod->stats_id = p_ll2_conn->tx_stats_id; in qed_sp_ll2_tx_queue_start()
1062 DMA_REGPAIR_LE(p_ramrod->pbl_base_addr, in qed_sp_ll2_tx_queue_start()
1063 qed_chain_get_pbl_phys(&p_tx->txq_chain)); in qed_sp_ll2_tx_queue_start()
1064 pbl_size = qed_chain_get_page_cnt(&p_tx->txq_chain); in qed_sp_ll2_tx_queue_start()
1065 p_ramrod->pbl_size = cpu_to_le16(pbl_size); in qed_sp_ll2_tx_queue_start()
1067 switch (p_ll2_conn->input.tx_tc) { in qed_sp_ll2_tx_queue_start()
1079 p_ramrod->qm_pq_id = cpu_to_le16(pq_id); in qed_sp_ll2_tx_queue_start()
1083 p_ramrod->conn_type = PROTOCOLID_FCOE; in qed_sp_ll2_tx_queue_start()
1086 p_ramrod->conn_type = PROTOCOLID_TCP_ULP; in qed_sp_ll2_tx_queue_start()
1089 p_ramrod->conn_type = PROTOCOLID_ROCE; in qed_sp_ll2_tx_queue_start()
1092 p_ramrod->conn_type = PROTOCOLID_IWARP; in qed_sp_ll2_tx_queue_start()
1095 if (p_hwfn->hw_info.personality == QED_PCI_ISCSI || in qed_sp_ll2_tx_queue_start()
1096 p_hwfn->hw_info.personality == QED_PCI_NVMETCP) in qed_sp_ll2_tx_queue_start()
1097 p_ramrod->conn_type = PROTOCOLID_TCP_ULP; in qed_sp_ll2_tx_queue_start()
1099 p_ramrod->conn_type = PROTOCOLID_IWARP; in qed_sp_ll2_tx_queue_start()
1102 p_ramrod->conn_type = PROTOCOLID_ETH; in qed_sp_ll2_tx_queue_start()
1106 p_ramrod->gsi_offload_flag = p_ll2_conn->input.gsi_enable; in qed_sp_ll2_tx_queue_start()
1112 rc = qed_db_recovery_add(p_hwfn->cdev, p_tx->doorbell_addr, in qed_sp_ll2_tx_queue_start()
1113 &p_tx->db_msg, DB_REC_WIDTH_32B, in qed_sp_ll2_tx_queue_start()
1124 int rc = -EINVAL; in qed_sp_ll2_rx_queue_stop()
1128 init_data.cid = p_ll2_conn->cid; in qed_sp_ll2_rx_queue_stop()
1129 init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_sp_ll2_rx_queue_stop()
1138 p_ramrod = &p_ent->ramrod.core_rx_queue_stop; in qed_sp_ll2_rx_queue_stop()
1140 p_ramrod->complete_event_flg = 1; in qed_sp_ll2_rx_queue_stop()
1141 p_ramrod->queue_id = p_ll2_conn->queue_id; in qed_sp_ll2_rx_queue_stop()
1149 struct qed_ll2_tx_queue *p_tx = &p_ll2_conn->tx_queue; in qed_sp_ll2_tx_queue_stop()
1152 int rc = -EINVAL; in qed_sp_ll2_tx_queue_stop()
1154 qed_db_recovery_del(p_hwfn->cdev, p_tx->doorbell_addr, &p_tx->db_msg); in qed_sp_ll2_tx_queue_stop()
1158 init_data.cid = p_ll2_conn->cid; in qed_sp_ll2_tx_queue_stop()
1159 init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; in qed_sp_ll2_tx_queue_stop()
1178 .num_elems = p_ll2_info->input.rx_num_desc, in qed_ll2_acquire_connection_rx()
1180 struct qed_dev *cdev = p_hwfn->cdev; in qed_ll2_acquire_connection_rx()
1185 if (!p_ll2_info->input.rx_num_desc) in qed_ll2_acquire_connection_rx()
1191 rc = qed_chain_alloc(cdev, &p_ll2_info->rx_queue.rxq_chain, ¶ms); in qed_ll2_acquire_connection_rx()
1197 capacity = qed_chain_get_capacity(&p_ll2_info->rx_queue.rxq_chain); in qed_ll2_acquire_connection_rx()
1201 rc = -ENOMEM; in qed_ll2_acquire_connection_rx()
1205 p_ll2_info->rx_queue.descq_array = p_descq; in qed_ll2_acquire_connection_rx()
1210 rc = qed_chain_alloc(cdev, &p_ll2_info->rx_queue.rcq_chain, ¶ms); in qed_ll2_acquire_connection_rx()
1218 p_ll2_info->input.conn_type, p_ll2_info->input.rx_num_desc); in qed_ll2_acquire_connection_rx()
1231 .num_elems = p_ll2_info->input.tx_num_desc, in qed_ll2_acquire_connection_tx()
1239 if (!p_ll2_info->input.tx_num_desc) in qed_ll2_acquire_connection_tx()
1242 rc = qed_chain_alloc(p_hwfn->cdev, &p_ll2_info->tx_queue.txq_chain, in qed_ll2_acquire_connection_tx()
1247 capacity = qed_chain_get_capacity(&p_ll2_info->tx_queue.txq_chain); in qed_ll2_acquire_connection_tx()
1250 p_ll2_info->input.tx_max_bds_per_packet); in qed_ll2_acquire_connection_tx()
1254 rc = -ENOMEM; in qed_ll2_acquire_connection_tx()
1257 p_ll2_info->tx_queue.descq_mem = p_descq; in qed_ll2_acquire_connection_tx()
1261 p_ll2_info->input.conn_type, p_ll2_info->input.tx_num_desc); in qed_ll2_acquire_connection_tx()
1267 p_ll2_info->input.tx_num_desc); in qed_ll2_acquire_connection_tx()
1280 if (p_ll2_info->input.conn_type != QED_LL2_TYPE_OOO) in qed_ll2_acquire_connection_ooo()
1284 if (!p_ll2_info->input.rx_num_ooo_buffers) { in qed_ll2_acquire_connection_ooo()
1285 u16 num_desc = p_ll2_info->input.rx_num_desc; in qed_ll2_acquire_connection_ooo()
1288 return -EINVAL; in qed_ll2_acquire_connection_ooo()
1289 p_ll2_info->input.rx_num_ooo_buffers = num_desc * 2; in qed_ll2_acquire_connection_ooo()
1292 for (buf_idx = 0; buf_idx < p_ll2_info->input.rx_num_ooo_buffers; in qed_ll2_acquire_connection_ooo()
1296 rc = -ENOMEM; in qed_ll2_acquire_connection_ooo()
1300 p_buf->rx_buffer_size = mtu + 26 + ETH_CACHE_LINE_SIZE; in qed_ll2_acquire_connection_ooo()
1301 p_buf->rx_buffer_size = (p_buf->rx_buffer_size + in qed_ll2_acquire_connection_ooo()
1302 ETH_CACHE_LINE_SIZE - 1) & in qed_ll2_acquire_connection_ooo()
1303 ~(ETH_CACHE_LINE_SIZE - 1); in qed_ll2_acquire_connection_ooo()
1304 p_virt = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, in qed_ll2_acquire_connection_ooo()
1305 p_buf->rx_buffer_size, in qed_ll2_acquire_connection_ooo()
1306 &p_buf->rx_buffer_phys_addr, in qed_ll2_acquire_connection_ooo()
1310 rc = -ENOMEM; in qed_ll2_acquire_connection_ooo()
1314 p_buf->rx_buffer_virt_addr = p_virt; in qed_ll2_acquire_connection_ooo()
1315 qed_ooo_put_free_buffer(p_hwfn, p_hwfn->p_ooo_info, p_buf); in qed_ll2_acquire_connection_ooo()
1320 p_ll2_info->input.rx_num_ooo_buffers, p_buf->rx_buffer_size); in qed_ll2_acquire_connection_ooo()
1329 if (!cbs || (!cbs->rx_comp_cb || in qed_ll2_set_cbs()
1330 !cbs->rx_release_cb || in qed_ll2_set_cbs()
1331 !cbs->tx_comp_cb || !cbs->tx_release_cb || !cbs->cookie)) in qed_ll2_set_cbs()
1332 return -EINVAL; in qed_ll2_set_cbs()
1334 p_ll2_info->cbs.rx_comp_cb = cbs->rx_comp_cb; in qed_ll2_set_cbs()
1335 p_ll2_info->cbs.rx_release_cb = cbs->rx_release_cb; in qed_ll2_set_cbs()
1336 p_ll2_info->cbs.tx_comp_cb = cbs->tx_comp_cb; in qed_ll2_set_cbs()
1337 p_ll2_info->cbs.tx_release_cb = cbs->tx_release_cb; in qed_ll2_set_cbs()
1338 p_ll2_info->cbs.slowpath_cb = cbs->slowpath_cb; in qed_ll2_set_cbs()
1339 p_ll2_info->cbs.cookie = cbs->cookie; in qed_ll2_set_cbs()
1351 if (data->input.rx_conn_type == QED_LL2_RX_TYPE_LEGACY) { in _qed_ll2_calc_allowed_conns()
1386 if (!data->p_connection_handle || !p_hwfn->p_ll2_info) in qed_ll2_acquire_connection()
1387 return -EINVAL; in qed_ll2_acquire_connection()
1393 mutex_lock(&p_hwfn->p_ll2_info[i].mutex); in qed_ll2_acquire_connection()
1394 if (p_hwfn->p_ll2_info[i].b_active) { in qed_ll2_acquire_connection()
1395 mutex_unlock(&p_hwfn->p_ll2_info[i].mutex); in qed_ll2_acquire_connection()
1399 p_hwfn->p_ll2_info[i].b_active = true; in qed_ll2_acquire_connection()
1400 p_ll2_info = &p_hwfn->p_ll2_info[i]; in qed_ll2_acquire_connection()
1401 mutex_unlock(&p_hwfn->p_ll2_info[i].mutex); in qed_ll2_acquire_connection()
1405 return -EBUSY; in qed_ll2_acquire_connection()
1407 memcpy(&p_ll2_info->input, &data->input, sizeof(p_ll2_info->input)); in qed_ll2_acquire_connection()
1409 switch (data->input.tx_dest) { in qed_ll2_acquire_connection()
1411 p_ll2_info->tx_dest = CORE_TX_DEST_NW; in qed_ll2_acquire_connection()
1414 p_ll2_info->tx_dest = CORE_TX_DEST_LB; in qed_ll2_acquire_connection()
1417 p_ll2_info->tx_dest = CORE_TX_DEST_DROP; in qed_ll2_acquire_connection()
1420 return -EINVAL; in qed_ll2_acquire_connection()
1423 if (data->input.conn_type == QED_LL2_TYPE_OOO || in qed_ll2_acquire_connection()
1424 data->input.secondary_queue) in qed_ll2_acquire_connection()
1425 p_ll2_info->main_func_queue = false; in qed_ll2_acquire_connection()
1427 p_ll2_info->main_func_queue = true; in qed_ll2_acquire_connection()
1430 p_tx_max = &p_ll2_info->input.tx_max_bds_per_packet; in qed_ll2_acquire_connection()
1437 rc = qed_ll2_set_cbs(p_ll2_info, data->cbs); in qed_ll2_acquire_connection()
1452 data->input.mtu); in qed_ll2_acquire_connection()
1457 if (data->input.conn_type == QED_LL2_TYPE_OOO) { in qed_ll2_acquire_connection()
1465 if (data->input.rx_num_desc) { in qed_ll2_acquire_connection()
1467 &p_hwfn->p_ll2_info[i], in qed_ll2_acquire_connection()
1468 &p_ll2_info->rx_queue.rx_sb_index, in qed_ll2_acquire_connection()
1469 &p_ll2_info->rx_queue.p_fw_cons); in qed_ll2_acquire_connection()
1470 p_ll2_info->rx_queue.b_cb_registered = true; in qed_ll2_acquire_connection()
1473 if (data->input.tx_num_desc) { in qed_ll2_acquire_connection()
1476 &p_hwfn->p_ll2_info[i], in qed_ll2_acquire_connection()
1477 &p_ll2_info->tx_queue.tx_sb_index, in qed_ll2_acquire_connection()
1478 &p_ll2_info->tx_queue.p_fw_cons); in qed_ll2_acquire_connection()
1479 p_ll2_info->tx_queue.b_cb_registered = true; in qed_ll2_acquire_connection()
1482 *data->p_connection_handle = i; in qed_ll2_acquire_connection()
1487 return -ENOMEM; in qed_ll2_acquire_connection()
1501 DIRECT_REG_WR(p_ll2_conn->rx_queue.set_prod_addr, 0x0); in qed_ll2_establish_connection_rx()
1502 error_input = p_ll2_conn->input.ai_err_packet_too_big; in qed_ll2_establish_connection_rx()
1506 error_input = p_ll2_conn->input.ai_err_no_buf; in qed_ll2_establish_connection_rx()
1514 if (p_ll2_conn->rx_queue.ctx_based) { in qed_ll2_establish_connection_rx()
1515 rc = qed_db_recovery_add(p_hwfn->cdev, in qed_ll2_establish_connection_rx()
1516 p_ll2_conn->rx_queue.set_prod_addr, in qed_ll2_establish_connection_rx()
1517 &p_ll2_conn->rx_queue.db_data, in qed_ll2_establish_connection_rx()
1528 if (p_ll2_conn->input.conn_type != QED_LL2_TYPE_OOO) in qed_ll2_establish_connection_ooo()
1531 qed_ooo_release_all_isles(p_hwfn, p_hwfn->p_ooo_info); in qed_ll2_establish_connection_ooo()
1542 return p_hwfn->hw_info.resc_start[QED_LL2_RAM_QUEUE] + handle; in qed_ll2_handle_to_queue_id()
1548 * and the queue ids above that are ctx base. in qed_ll2_handle_to_queue_id()
1550 qid = p_hwfn->hw_info.resc_start[QED_LL2_CTX_QUEUE] + in qed_ll2_handle_to_queue_id()
1556 qid += (handle - QED_MAX_NUM_OF_LEGACY_LL2_CONNS_PF); in qed_ll2_handle_to_queue_id()
1571 int rc = -EINVAL; in qed_ll2_establish_connection()
1578 return -EAGAIN; in qed_ll2_establish_connection()
1582 rc = -EINVAL; in qed_ll2_establish_connection()
1586 p_rx = &p_ll2_conn->rx_queue; in qed_ll2_establish_connection()
1587 p_tx = &p_ll2_conn->tx_queue; in qed_ll2_establish_connection()
1589 qed_chain_reset(&p_rx->rxq_chain); in qed_ll2_establish_connection()
1590 qed_chain_reset(&p_rx->rcq_chain); in qed_ll2_establish_connection()
1591 INIT_LIST_HEAD(&p_rx->active_descq); in qed_ll2_establish_connection()
1592 INIT_LIST_HEAD(&p_rx->free_descq); in qed_ll2_establish_connection()
1593 INIT_LIST_HEAD(&p_rx->posting_descq); in qed_ll2_establish_connection()
1594 spin_lock_init(&p_rx->lock); in qed_ll2_establish_connection()
1595 capacity = qed_chain_get_capacity(&p_rx->rxq_chain); in qed_ll2_establish_connection()
1597 list_add_tail(&p_rx->descq_array[i].list_entry, in qed_ll2_establish_connection()
1598 &p_rx->free_descq); in qed_ll2_establish_connection()
1599 *p_rx->p_fw_cons = 0; in qed_ll2_establish_connection()
1601 qed_chain_reset(&p_tx->txq_chain); in qed_ll2_establish_connection()
1602 INIT_LIST_HEAD(&p_tx->active_descq); in qed_ll2_establish_connection()
1603 INIT_LIST_HEAD(&p_tx->free_descq); in qed_ll2_establish_connection()
1604 INIT_LIST_HEAD(&p_tx->sending_descq); in qed_ll2_establish_connection()
1605 spin_lock_init(&p_tx->lock); in qed_ll2_establish_connection()
1606 capacity = qed_chain_get_capacity(&p_tx->txq_chain); in qed_ll2_establish_connection()
1609 p_ll2_conn->input.tx_max_bds_per_packet); in qed_ll2_establish_connection()
1612 p_pkt = p_tx->descq_mem + desc_size * i; in qed_ll2_establish_connection()
1613 list_add_tail(&p_pkt->list_entry, &p_tx->free_descq); in qed_ll2_establish_connection()
1615 p_tx->cur_completing_bd_idx = 0; in qed_ll2_establish_connection()
1616 p_tx->bds_idx = 0; in qed_ll2_establish_connection()
1617 p_tx->b_completing_packet = false; in qed_ll2_establish_connection()
1618 p_tx->cur_send_packet = NULL; in qed_ll2_establish_connection()
1619 p_tx->cur_send_frag_num = 0; in qed_ll2_establish_connection()
1620 p_tx->cur_completing_frag_num = 0; in qed_ll2_establish_connection()
1621 *p_tx->p_fw_cons = 0; in qed_ll2_establish_connection()
1623 rc = qed_cxt_acquire_cid(p_hwfn, PROTOCOLID_CORE, &p_ll2_conn->cid); in qed_ll2_establish_connection()
1626 cxt_info.iid = p_ll2_conn->cid; in qed_ll2_establish_connection()
1630 p_ll2_conn->cid); in qed_ll2_establish_connection()
1639 p_ll2_conn->input.rx_conn_type); in qed_ll2_establish_connection()
1641 p_ll2_conn->input.rx_conn_type, in qed_ll2_establish_connection()
1643 p_ll2_conn->queue_id = qid; in qed_ll2_establish_connection()
1644 p_ll2_conn->tx_stats_id = stats_id; in qed_ll2_establish_connection()
1647 if (p_ll2_conn->tx_stats_id == QED_LL2_INVALID_STATS_ID) { in qed_ll2_establish_connection()
1648 p_ll2_conn->tx_stats_en = 0; in qed_ll2_establish_connection()
1651 "Disabling stats for queue %d - not enough counters\n", in qed_ll2_establish_connection()
1658 p_hwfn->rel_pf_id, in qed_ll2_establish_connection()
1659 p_ll2_conn->input.rx_conn_type, qid, stats_id); in qed_ll2_establish_connection()
1661 if (p_ll2_conn->input.rx_conn_type == QED_LL2_RX_TYPE_LEGACY) { in qed_ll2_establish_connection()
1662 p_rx->set_prod_addr = in qed_ll2_establish_connection()
1663 (u8 __iomem *)p_hwfn->regview + in qed_ll2_establish_connection()
1667 /* QED_LL2_RX_TYPE_CTX - using doorbell */ in qed_ll2_establish_connection()
1668 p_rx->ctx_based = 1; in qed_ll2_establish_connection()
1670 p_rx->set_prod_addr = p_hwfn->doorbells + in qed_ll2_establish_connection()
1671 p_hwfn->dpi_start_offset + in qed_ll2_establish_connection()
1675 p_rx->db_data.icid = cpu_to_le16((u16)p_ll2_conn->cid); in qed_ll2_establish_connection()
1676 SET_FIELD(p_rx->db_data.params, in qed_ll2_establish_connection()
1678 SET_FIELD(p_rx->db_data.params, in qed_ll2_establish_connection()
1682 p_tx->doorbell_addr = (u8 __iomem *)p_hwfn->doorbells + in qed_ll2_establish_connection()
1683 qed_db_addr(p_ll2_conn->cid, in qed_ll2_establish_connection()
1686 SET_FIELD(p_tx->db_msg.params, CORE_DB_DATA_DEST, DB_DEST_XCM); in qed_ll2_establish_connection()
1687 SET_FIELD(p_tx->db_msg.params, CORE_DB_DATA_AGG_CMD, DB_AGG_CMD_SET); in qed_ll2_establish_connection()
1688 SET_FIELD(p_tx->db_msg.params, CORE_DB_DATA_AGG_VAL_SEL, in qed_ll2_establish_connection()
1690 p_tx->db_msg.agg_flags = DQ_XCM_CORE_DQ_CF_CMD; in qed_ll2_establish_connection()
1706 if (p_ll2_conn->input.conn_type == QED_LL2_TYPE_FCOE) { in qed_ll2_establish_connection()
1707 if (!test_bit(QED_MF_UFP_SPECIFIC, &p_hwfn->cdev->mf_bits)) in qed_ll2_establish_connection()
1708 qed_llh_add_protocol_filter(p_hwfn->cdev, 0, in qed_ll2_establish_connection()
1711 qed_llh_add_protocol_filter(p_hwfn->cdev, 0, in qed_ll2_establish_connection()
1731 while (!list_empty(&p_rx->posting_descq)) { in qed_ll2_post_rx_buffer_notify_fw()
1732 p_posting_packet = list_first_entry(&p_rx->posting_descq, in qed_ll2_post_rx_buffer_notify_fw()
1735 list_move_tail(&p_posting_packet->list_entry, in qed_ll2_post_rx_buffer_notify_fw()
1736 &p_rx->active_descq); in qed_ll2_post_rx_buffer_notify_fw()
1742 list_add_tail(&p_curp->list_entry, &p_rx->active_descq); in qed_ll2_post_rx_buffer_notify_fw()
1749 bd_prod = qed_chain_get_prod_idx(&p_rx->rxq_chain); in qed_ll2_post_rx_buffer_notify_fw()
1750 cq_prod = qed_chain_get_prod_idx(&p_rx->rcq_chain); in qed_ll2_post_rx_buffer_notify_fw()
1751 if (p_rx->ctx_based) { in qed_ll2_post_rx_buffer_notify_fw()
1753 p_rx->db_data.prod.bd_prod = cpu_to_le16(bd_prod); in qed_ll2_post_rx_buffer_notify_fw()
1754 p_rx->db_data.prod.cqe_prod = cpu_to_le16(cq_prod); in qed_ll2_post_rx_buffer_notify_fw()
1759 DIRECT_REG_WR64(p_rx->set_prod_addr, in qed_ll2_post_rx_buffer_notify_fw()
1760 *((u64 *)&p_rx->db_data)); in qed_ll2_post_rx_buffer_notify_fw()
1770 DIRECT_REG_WR(p_rx->set_prod_addr, *((u32 *)&rx_prod)); in qed_ll2_post_rx_buffer_notify_fw()
1790 return -EINVAL; in qed_ll2_post_rx_buffer()
1791 p_rx = &p_ll2_conn->rx_queue; in qed_ll2_post_rx_buffer()
1792 if (!p_rx->set_prod_addr) in qed_ll2_post_rx_buffer()
1793 return -EIO; in qed_ll2_post_rx_buffer()
1795 spin_lock_irqsave(&p_rx->lock, flags); in qed_ll2_post_rx_buffer()
1796 if (!list_empty(&p_rx->free_descq)) in qed_ll2_post_rx_buffer()
1797 p_curp = list_first_entry(&p_rx->free_descq, in qed_ll2_post_rx_buffer()
1800 if (qed_chain_get_elem_left(&p_rx->rxq_chain) && in qed_ll2_post_rx_buffer()
1801 qed_chain_get_elem_left(&p_rx->rcq_chain)) { in qed_ll2_post_rx_buffer()
1802 p_data = qed_chain_produce(&p_rx->rxq_chain); in qed_ll2_post_rx_buffer()
1804 qed_chain_produce(&p_rx->rcq_chain); in qed_ll2_post_rx_buffer()
1810 rc = -EBUSY; in qed_ll2_post_rx_buffer()
1816 DMA_REGPAIR_LE(p_curb->addr, addr); in qed_ll2_post_rx_buffer()
1817 p_curb->buff_length = cpu_to_le16(buf_len); in qed_ll2_post_rx_buffer()
1818 p_curp->rx_buf_addr = addr; in qed_ll2_post_rx_buffer()
1819 p_curp->cookie = cookie; in qed_ll2_post_rx_buffer()
1820 p_curp->rxq_bd = p_curb; in qed_ll2_post_rx_buffer()
1821 p_curp->buf_length = buf_len; in qed_ll2_post_rx_buffer()
1822 list_del(&p_curp->list_entry); in qed_ll2_post_rx_buffer()
1826 list_add_tail(&p_curp->list_entry, &p_rx->posting_descq); in qed_ll2_post_rx_buffer()
1833 spin_unlock_irqrestore(&p_rx->lock, flags); in qed_ll2_post_rx_buffer()
1843 list_del(&p_curp->list_entry); in qed_ll2_prepare_tx_packet_set()
1844 p_curp->cookie = pkt->cookie; in qed_ll2_prepare_tx_packet_set()
1845 p_curp->bd_used = pkt->num_of_bds; in qed_ll2_prepare_tx_packet_set()
1846 p_curp->notify_fw = notify_fw; in qed_ll2_prepare_tx_packet_set()
1847 p_tx->cur_send_packet = p_curp; in qed_ll2_prepare_tx_packet_set()
1848 p_tx->cur_send_frag_num = 0; in qed_ll2_prepare_tx_packet_set()
1850 p_curp->bds_set[p_tx->cur_send_frag_num].tx_frag = pkt->first_frag; in qed_ll2_prepare_tx_packet_set()
1851 p_curp->bds_set[p_tx->cur_send_frag_num].frag_len = pkt->first_frag_len; in qed_ll2_prepare_tx_packet_set()
1852 p_tx->cur_send_frag_num++; in qed_ll2_prepare_tx_packet_set()
1861 struct qed_chain *p_tx_chain = &p_ll2->tx_queue.txq_chain; in qed_ll2_prepare_tx_packet_set_bd()
1869 roce_flavor = (pkt->qed_roce_flavor == QED_LL2_ROCE) ? CORE_ROCE in qed_ll2_prepare_tx_packet_set_bd()
1872 switch (pkt->tx_dest) { in qed_ll2_prepare_tx_packet_set_bd()
1889 p_ll2->input.conn_type == QED_LL2_TYPE_OOO)) { in qed_ll2_prepare_tx_packet_set_bd()
1890 start_bd->nw_vlan_or_lb_echo = in qed_ll2_prepare_tx_packet_set_bd()
1893 start_bd->nw_vlan_or_lb_echo = cpu_to_le16(pkt->vlan); in qed_ll2_prepare_tx_packet_set_bd()
1894 if (test_bit(QED_MF_UFP_SPECIFIC, &p_hwfn->cdev->mf_bits) && in qed_ll2_prepare_tx_packet_set_bd()
1895 p_ll2->input.conn_type == QED_LL2_TYPE_FCOE) in qed_ll2_prepare_tx_packet_set_bd()
1896 pkt->remove_stag = true; in qed_ll2_prepare_tx_packet_set_bd()
1899 bitfield1 = le16_to_cpu(start_bd->bitfield1); in qed_ll2_prepare_tx_packet_set_bd()
1900 SET_FIELD(bitfield1, CORE_TX_BD_L4_HDR_OFFSET_W, pkt->l4_hdr_offset_w); in qed_ll2_prepare_tx_packet_set_bd()
1902 start_bd->bitfield1 = cpu_to_le16(bitfield1); in qed_ll2_prepare_tx_packet_set_bd()
1904 bd_data |= pkt->bd_flags; in qed_ll2_prepare_tx_packet_set_bd()
1906 SET_FIELD(bd_data, CORE_TX_BD_DATA_NBDS, pkt->num_of_bds); in qed_ll2_prepare_tx_packet_set_bd()
1908 SET_FIELD(bd_data, CORE_TX_BD_DATA_IP_CSUM, !!(pkt->enable_ip_cksum)); in qed_ll2_prepare_tx_packet_set_bd()
1909 SET_FIELD(bd_data, CORE_TX_BD_DATA_L4_CSUM, !!(pkt->enable_l4_cksum)); in qed_ll2_prepare_tx_packet_set_bd()
1910 SET_FIELD(bd_data, CORE_TX_BD_DATA_IP_LEN, !!(pkt->calc_ip_len)); in qed_ll2_prepare_tx_packet_set_bd()
1912 !!(pkt->remove_stag)); in qed_ll2_prepare_tx_packet_set_bd()
1914 start_bd->bd_data.as_bitfield = cpu_to_le16(bd_data); in qed_ll2_prepare_tx_packet_set_bd()
1915 DMA_REGPAIR_LE(start_bd->addr, pkt->first_frag); in qed_ll2_prepare_tx_packet_set_bd()
1916 start_bd->nbytes = cpu_to_le16(pkt->first_frag_len); in qed_ll2_prepare_tx_packet_set_bd()
1920 …"LL2 [q 0x%02x cid 0x%08x type 0x%08x] Tx Producer at [0x%04x] - set with a %04x bytes %02x BDs bu… in qed_ll2_prepare_tx_packet_set_bd()
1921 p_ll2->queue_id, in qed_ll2_prepare_tx_packet_set_bd()
1922 p_ll2->cid, in qed_ll2_prepare_tx_packet_set_bd()
1923 p_ll2->input.conn_type, in qed_ll2_prepare_tx_packet_set_bd()
1925 pkt->first_frag_len, in qed_ll2_prepare_tx_packet_set_bd()
1926 pkt->num_of_bds, in qed_ll2_prepare_tx_packet_set_bd()
1927 le32_to_cpu(start_bd->addr.hi), in qed_ll2_prepare_tx_packet_set_bd()
1928 le32_to_cpu(start_bd->addr.lo)); in qed_ll2_prepare_tx_packet_set_bd()
1930 if (p_ll2->tx_queue.cur_send_frag_num == pkt->num_of_bds) in qed_ll2_prepare_tx_packet_set_bd()
1934 for (frag_idx = p_ll2->tx_queue.cur_send_frag_num; in qed_ll2_prepare_tx_packet_set_bd()
1935 frag_idx < pkt->num_of_bds; frag_idx++) { in qed_ll2_prepare_tx_packet_set_bd()
1936 struct core_tx_bd **p_bd = &p_curp->bds_set[frag_idx].txq_bd; in qed_ll2_prepare_tx_packet_set_bd()
1939 (*p_bd)->bd_data.as_bitfield = 0; in qed_ll2_prepare_tx_packet_set_bd()
1940 (*p_bd)->bitfield1 = 0; in qed_ll2_prepare_tx_packet_set_bd()
1941 p_curp->bds_set[frag_idx].tx_frag = 0; in qed_ll2_prepare_tx_packet_set_bd()
1942 p_curp->bds_set[frag_idx].frag_len = 0; in qed_ll2_prepare_tx_packet_set_bd()
1950 bool b_notify = p_ll2_conn->tx_queue.cur_send_packet->notify_fw; in qed_ll2_tx_packet_notify()
1951 struct qed_ll2_tx_queue *p_tx = &p_ll2_conn->tx_queue; in qed_ll2_tx_packet_notify()
1956 if (p_ll2_conn->tx_queue.cur_send_frag_num != in qed_ll2_tx_packet_notify()
1957 p_ll2_conn->tx_queue.cur_send_packet->bd_used) in qed_ll2_tx_packet_notify()
1961 list_add_tail(&p_ll2_conn->tx_queue.cur_send_packet->list_entry, in qed_ll2_tx_packet_notify()
1962 &p_ll2_conn->tx_queue.sending_descq); in qed_ll2_tx_packet_notify()
1963 p_ll2_conn->tx_queue.cur_send_packet = NULL; in qed_ll2_tx_packet_notify()
1964 p_ll2_conn->tx_queue.cur_send_frag_num = 0; in qed_ll2_tx_packet_notify()
1970 bd_prod = qed_chain_get_prod_idx(&p_ll2_conn->tx_queue.txq_chain); in qed_ll2_tx_packet_notify()
1972 while (!list_empty(&p_tx->sending_descq)) { in qed_ll2_tx_packet_notify()
1973 p_pkt = list_first_entry(&p_tx->sending_descq, in qed_ll2_tx_packet_notify()
1978 list_move_tail(&p_pkt->list_entry, &p_tx->active_descq); in qed_ll2_tx_packet_notify()
1981 p_tx->db_msg.spq_prod = cpu_to_le16(bd_prod); in qed_ll2_tx_packet_notify()
1986 DIRECT_REG_WR(p_tx->doorbell_addr, *((u32 *)&p_tx->db_msg)); in qed_ll2_tx_packet_notify()
1991 p_ll2_conn->queue_id, in qed_ll2_tx_packet_notify()
1992 p_ll2_conn->cid, in qed_ll2_tx_packet_notify()
1993 p_ll2_conn->input.conn_type, p_tx->db_msg.spq_prod); in qed_ll2_tx_packet_notify()
2011 return -EINVAL; in qed_ll2_prepare_tx_packet()
2012 p_tx = &p_ll2_conn->tx_queue; in qed_ll2_prepare_tx_packet()
2013 p_tx_chain = &p_tx->txq_chain; in qed_ll2_prepare_tx_packet()
2015 if (unlikely(pkt->num_of_bds > p_ll2_conn->input.tx_max_bds_per_packet)) in qed_ll2_prepare_tx_packet()
2016 return -EIO; in qed_ll2_prepare_tx_packet()
2018 spin_lock_irqsave(&p_tx->lock, flags); in qed_ll2_prepare_tx_packet()
2019 if (unlikely(p_tx->cur_send_packet)) { in qed_ll2_prepare_tx_packet()
2020 rc = -EEXIST; in qed_ll2_prepare_tx_packet()
2025 if (unlikely(!list_empty(&p_tx->free_descq))) in qed_ll2_prepare_tx_packet()
2026 p_curp = list_first_entry(&p_tx->free_descq, in qed_ll2_prepare_tx_packet()
2029 qed_chain_get_elem_left(p_tx_chain) < pkt->num_of_bds)) in qed_ll2_prepare_tx_packet()
2033 rc = -EBUSY; in qed_ll2_prepare_tx_packet()
2045 spin_unlock_irqrestore(&p_tx->lock, flags); in qed_ll2_prepare_tx_packet()
2062 return -EINVAL; in qed_ll2_set_fragment_of_tx_packet()
2064 if (unlikely(!p_ll2_conn->tx_queue.cur_send_packet)) in qed_ll2_set_fragment_of_tx_packet()
2065 return -EINVAL; in qed_ll2_set_fragment_of_tx_packet()
2067 p_cur_send_packet = p_ll2_conn->tx_queue.cur_send_packet; in qed_ll2_set_fragment_of_tx_packet()
2068 cur_send_frag_num = p_ll2_conn->tx_queue.cur_send_frag_num; in qed_ll2_set_fragment_of_tx_packet()
2070 if (unlikely(cur_send_frag_num >= p_cur_send_packet->bd_used)) in qed_ll2_set_fragment_of_tx_packet()
2071 return -EINVAL; in qed_ll2_set_fragment_of_tx_packet()
2074 p_bd = p_cur_send_packet->bds_set[cur_send_frag_num].txq_bd; in qed_ll2_set_fragment_of_tx_packet()
2075 DMA_REGPAIR_LE(p_bd->addr, addr); in qed_ll2_set_fragment_of_tx_packet()
2076 p_bd->nbytes = cpu_to_le16(nbytes); in qed_ll2_set_fragment_of_tx_packet()
2077 p_cur_send_packet->bds_set[cur_send_frag_num].tx_frag = addr; in qed_ll2_set_fragment_of_tx_packet()
2078 p_cur_send_packet->bds_set[cur_send_frag_num].frag_len = nbytes; in qed_ll2_set_fragment_of_tx_packet()
2080 p_ll2_conn->tx_queue.cur_send_frag_num++; in qed_ll2_set_fragment_of_tx_packet()
2082 spin_lock_irqsave(&p_ll2_conn->tx_queue.lock, flags); in qed_ll2_set_fragment_of_tx_packet()
2084 spin_unlock_irqrestore(&p_ll2_conn->tx_queue.lock, flags); in qed_ll2_set_fragment_of_tx_packet()
2093 int rc = -EINVAL; in qed_ll2_terminate_connection()
2098 return -EAGAIN; in qed_ll2_terminate_connection()
2102 rc = -EINVAL; in qed_ll2_terminate_connection()
2108 p_ll2_conn->tx_queue.b_cb_registered = false; in qed_ll2_terminate_connection()
2115 qed_int_unregister_cb(p_hwfn, p_ll2_conn->tx_queue.tx_sb_index); in qed_ll2_terminate_connection()
2119 p_ll2_conn->rx_queue.b_cb_registered = false; in qed_ll2_terminate_connection()
2122 if (p_ll2_conn->rx_queue.ctx_based) in qed_ll2_terminate_connection()
2123 qed_db_recovery_del(p_hwfn->cdev, in qed_ll2_terminate_connection()
2124 p_ll2_conn->rx_queue.set_prod_addr, in qed_ll2_terminate_connection()
2125 &p_ll2_conn->rx_queue.db_data); in qed_ll2_terminate_connection()
2132 qed_int_unregister_cb(p_hwfn, p_ll2_conn->rx_queue.rx_sb_index); in qed_ll2_terminate_connection()
2135 if (p_ll2_conn->input.conn_type == QED_LL2_TYPE_OOO) in qed_ll2_terminate_connection()
2136 qed_ooo_release_all_isles(p_hwfn, p_hwfn->p_ooo_info); in qed_ll2_terminate_connection()
2138 if (p_ll2_conn->input.conn_type == QED_LL2_TYPE_FCOE) { in qed_ll2_terminate_connection()
2139 if (!test_bit(QED_MF_UFP_SPECIFIC, &p_hwfn->cdev->mf_bits)) in qed_ll2_terminate_connection()
2140 qed_llh_remove_protocol_filter(p_hwfn->cdev, 0, in qed_ll2_terminate_connection()
2143 qed_llh_remove_protocol_filter(p_hwfn->cdev, 0, in qed_ll2_terminate_connection()
2158 if (p_ll2_conn->input.conn_type != QED_LL2_TYPE_OOO) in qed_ll2_release_connection_ooo()
2161 qed_ooo_release_all_isles(p_hwfn, p_hwfn->p_ooo_info); in qed_ll2_release_connection_ooo()
2163 p_hwfn->p_ooo_info))) { in qed_ll2_release_connection_ooo()
2164 dma_free_coherent(&p_hwfn->cdev->pdev->dev, in qed_ll2_release_connection_ooo()
2165 p_buffer->rx_buffer_size, in qed_ll2_release_connection_ooo()
2166 p_buffer->rx_buffer_virt_addr, in qed_ll2_release_connection_ooo()
2167 p_buffer->rx_buffer_phys_addr); in qed_ll2_release_connection_ooo()
2181 kfree(p_ll2_conn->tx_queue.descq_mem); in qed_ll2_release_connection()
2182 qed_chain_free(p_hwfn->cdev, &p_ll2_conn->tx_queue.txq_chain); in qed_ll2_release_connection()
2184 kfree(p_ll2_conn->rx_queue.descq_array); in qed_ll2_release_connection()
2185 qed_chain_free(p_hwfn->cdev, &p_ll2_conn->rx_queue.rxq_chain); in qed_ll2_release_connection()
2186 qed_chain_free(p_hwfn->cdev, &p_ll2_conn->rx_queue.rcq_chain); in qed_ll2_release_connection()
2188 qed_cxt_release_cid(p_hwfn, p_ll2_conn->cid); in qed_ll2_release_connection()
2192 mutex_lock(&p_ll2_conn->mutex); in qed_ll2_release_connection()
2193 p_ll2_conn->b_active = false; in qed_ll2_release_connection()
2194 mutex_unlock(&p_ll2_conn->mutex); in qed_ll2_release_connection()
2207 return -ENOMEM; in qed_ll2_alloc()
2213 p_hwfn->p_ll2_info = p_ll2_connections; in qed_ll2_alloc()
2222 mutex_init(&p_hwfn->p_ll2_info[i].mutex); in qed_ll2_setup()
2227 if (!p_hwfn->p_ll2_info) in qed_ll2_free()
2230 kfree(p_hwfn->p_ll2_info); in qed_ll2_free()
2231 p_hwfn->p_ll2_info = NULL; in qed_ll2_free()
2246 p_stats->gsi_invalid_hdr += HILO_64_REGPAIR(port_stats.gsi_invalid_hdr); in _qed_ll2_get_port_stats()
2247 p_stats->gsi_invalid_pkt_length += in _qed_ll2_get_port_stats()
2249 p_stats->gsi_unsupported_pkt_typ += in _qed_ll2_get_port_stats()
2251 p_stats->gsi_crcchksm_error += in _qed_ll2_get_port_stats()
2261 u8 qid = p_ll2_conn->queue_id; in _qed_ll2_get_tstats()
2269 p_stats->packet_too_big_discard += in _qed_ll2_get_tstats()
2271 p_stats->no_buff_discard += HILO_64_REGPAIR(tstats.no_buff_discard); in _qed_ll2_get_tstats()
2280 u8 qid = p_ll2_conn->queue_id; in _qed_ll2_get_ustats()
2288 p_stats->rcv_ucast_bytes += HILO_64_REGPAIR(ustats.rcv_ucast_bytes); in _qed_ll2_get_ustats()
2289 p_stats->rcv_mcast_bytes += HILO_64_REGPAIR(ustats.rcv_mcast_bytes); in _qed_ll2_get_ustats()
2290 p_stats->rcv_bcast_bytes += HILO_64_REGPAIR(ustats.rcv_bcast_bytes); in _qed_ll2_get_ustats()
2291 p_stats->rcv_ucast_pkts += HILO_64_REGPAIR(ustats.rcv_ucast_pkts); in _qed_ll2_get_ustats()
2292 p_stats->rcv_mcast_pkts += HILO_64_REGPAIR(ustats.rcv_mcast_pkts); in _qed_ll2_get_ustats()
2293 p_stats->rcv_bcast_pkts += HILO_64_REGPAIR(ustats.rcv_bcast_pkts); in _qed_ll2_get_ustats()
2302 u8 stats_id = p_ll2_conn->tx_stats_id; in _qed_ll2_get_pstats()
2310 p_stats->sent_ucast_bytes += HILO_64_REGPAIR(pstats.sent_ucast_bytes); in _qed_ll2_get_pstats()
2311 p_stats->sent_mcast_bytes += HILO_64_REGPAIR(pstats.sent_mcast_bytes); in _qed_ll2_get_pstats()
2312 p_stats->sent_bcast_bytes += HILO_64_REGPAIR(pstats.sent_bcast_bytes); in _qed_ll2_get_pstats()
2313 p_stats->sent_ucast_pkts += HILO_64_REGPAIR(pstats.sent_ucast_pkts); in _qed_ll2_get_pstats()
2314 p_stats->sent_mcast_pkts += HILO_64_REGPAIR(pstats.sent_mcast_pkts); in _qed_ll2_get_pstats()
2315 p_stats->sent_bcast_pkts += HILO_64_REGPAIR(pstats.sent_bcast_pkts); in _qed_ll2_get_pstats()
2326 !p_hwfn->p_ll2_info) in __qed_ll2_get_stats()
2327 return -EINVAL; in __qed_ll2_get_stats()
2329 p_ll2_conn = &p_hwfn->p_ll2_info[connection_handle]; in __qed_ll2_get_stats()
2334 return -EINVAL; in __qed_ll2_get_stats()
2337 if (p_ll2_conn->input.gsi_enable) in __qed_ll2_get_stats()
2344 if (p_ll2_conn->tx_stats_en) in __qed_ll2_get_stats()
2367 qed_ll2_dealloc_buffer(p_hwfn->cdev, cookie); in qed_ll2b_release_rx_packet()
2374 cdev->ll2->cbs = ops; in qed_ll2_register_cb_ops()
2375 cdev->ll2->cb_cookie = cookie; in qed_ll2_register_cb_ops()
2393 data->input.conn_type = conn_type; in qed_ll2_set_conn_data()
2394 data->input.mtu = params->mtu; in qed_ll2_set_conn_data()
2395 data->input.rx_num_desc = QED_LL2_RX_SIZE; in qed_ll2_set_conn_data()
2396 data->input.rx_drop_ttl0_flg = params->drop_ttl0_packets; in qed_ll2_set_conn_data()
2397 data->input.rx_vlan_removal_en = params->rx_vlan_stripping; in qed_ll2_set_conn_data()
2398 data->input.tx_num_desc = QED_LL2_TX_SIZE; in qed_ll2_set_conn_data()
2399 data->p_connection_handle = handle; in qed_ll2_set_conn_data()
2400 data->cbs = &ll2_cbs; in qed_ll2_set_conn_data()
2404 data->input.tx_tc = PKT_LB_TC; in qed_ll2_set_conn_data()
2405 data->input.tx_dest = QED_LL2_TX_DEST_LB; in qed_ll2_set_conn_data()
2407 data->input.tx_tc = 0; in qed_ll2_set_conn_data()
2408 data->input.tx_dest = QED_LL2_TX_DEST_NW; in qed_ll2_set_conn_data()
2415 u8 *handle = &p_hwfn->pf_params.iscsi_pf_params.ll2_ooo_queue_id; in qed_ll2_start_ooo()
2453 struct qed_dev *cdev = p_hwfn->cdev; in __qed_ll2_stop()
2456 rc = qed_ll2_terminate_connection(p_hwfn, cdev->ll2->handle); in __qed_ll2_stop()
2460 qed_ll2_release_connection(p_hwfn, cdev->ll2->handle); in __qed_ll2_stop()
2471 if (cdev->ll2->handle == QED_LL2_UNUSED_HANDLE) in qed_ll2_stop()
2474 qed_llh_remove_mac_filter(cdev, 0, cdev->ll2_mac_address); in qed_ll2_stop()
2476 qed_llh_remove_mac_filter(cdev, 0, cdev->ll2_mac_address); in qed_ll2_stop()
2477 eth_zero_addr(cdev->ll2_mac_address); in qed_ll2_stop()
2496 cdev->ll2->handle = QED_LL2_UNUSED_HANDLE; in qed_ll2_stop()
2505 struct qed_dev *cdev = p_hwfn->cdev; in __qed_ll2_start()
2510 switch (p_hwfn->hw_info.personality) { in __qed_ll2_start()
2527 &cdev->ll2->handle, false); in __qed_ll2_start()
2535 rc = qed_ll2_establish_connection(p_hwfn, cdev->ll2->handle); in __qed_ll2_start()
2542 spin_lock_bh(&cdev->ll2->lock); in __qed_ll2_start()
2543 rx_cnt = cdev->ll2->rx_cnt; in __qed_ll2_start()
2544 list_for_each_entry_safe(buffer, tmp_buffer, &cdev->ll2->list, list) { in __qed_ll2_start()
2546 cdev->ll2->handle, in __qed_ll2_start()
2547 buffer->phys_addr, 0, buffer, 1); in __qed_ll2_start()
2551 dma_unmap_single(&cdev->pdev->dev, buffer->phys_addr, in __qed_ll2_start()
2552 cdev->ll2->rx_size, DMA_FROM_DEVICE); in __qed_ll2_start()
2553 kfree(buffer->data); in __qed_ll2_start()
2554 list_del(&buffer->list); in __qed_ll2_start()
2560 spin_unlock_bh(&cdev->ll2->lock); in __qed_ll2_start()
2562 if (rx_cnt == cdev->ll2->rx_cnt) { in __qed_ll2_start()
2566 cdev->ll2->rx_cnt = rx_cnt; in __qed_ll2_start()
2571 qed_ll2_terminate_connection(p_hwfn, cdev->ll2->handle); in __qed_ll2_start()
2573 qed_ll2_release_connection(p_hwfn, cdev->ll2->handle); in __qed_ll2_start()
2584 if (!is_valid_ether_addr(params->ll2_mac_address)) { in qed_ll2_start()
2586 return -EINVAL; in qed_ll2_start()
2589 WARN_ON(!cdev->ll2->cbs); in qed_ll2_start()
2592 INIT_LIST_HEAD(&cdev->ll2->list); in qed_ll2_start()
2593 spin_lock_init(&cdev->ll2->lock); in qed_ll2_start()
2595 cdev->ll2->rx_size = PRM_DMA_PAD_BYTES_NUM + ETH_HLEN + in qed_ll2_start()
2596 L1_CACHE_BYTES + params->mtu; in qed_ll2_start()
2604 rx_num_desc, cdev->ll2->rx_size); in qed_ll2_start()
2609 rc = -ENOMEM; in qed_ll2_start()
2613 rc = qed_ll2_alloc_buffer(cdev, (u8 **)&buffer->data, in qed_ll2_start()
2614 &buffer->phys_addr); in qed_ll2_start()
2620 list_add_tail(&buffer->list, &cdev->ll2->list); in qed_ll2_start()
2651 rc = qed_llh_add_mac_filter(cdev, 0, params->ll2_mac_address); in qed_ll2_start()
2658 ether_addr_copy(cdev->ll2_mac_address, params->ll2_mac_address); in qed_ll2_start()
2672 cdev->ll2->handle = QED_LL2_UNUSED_HANDLE; in qed_ll2_start()
2683 int rc = -EINVAL, i; in qed_ll2_start_xmit()
2687 if (unlikely(skb->ip_summed != CHECKSUM_NONE)) { in qed_ll2_start_xmit()
2689 return -EINVAL; in qed_ll2_start_xmit()
2695 nr_frags = skb_shinfo(skb)->nr_frags; in qed_ll2_start_xmit()
2700 return -EINVAL; in qed_ll2_start_xmit()
2703 mapping = dma_map_single(&cdev->pdev->dev, skb->data, in qed_ll2_start_xmit()
2704 skb->len, DMA_TO_DEVICE); in qed_ll2_start_xmit()
2705 if (unlikely(dma_mapping_error(&cdev->pdev->dev, mapping))) { in qed_ll2_start_xmit()
2707 return -EINVAL; in qed_ll2_start_xmit()
2712 ipv6_hdr(skb)->nexthdr == NEXTHDR_IPV6)) in qed_ll2_start_xmit()
2726 pkt.first_frag_len = skb->len; in qed_ll2_start_xmit()
2728 if (test_bit(QED_MF_UFP_SPECIFIC, &cdev->mf_bits) && in qed_ll2_start_xmit()
2737 rc = qed_ll2_prepare_tx_packet(p_hwfn, cdev->ll2->handle, in qed_ll2_start_xmit()
2743 frag = &skb_shinfo(skb)->frags[i]; in qed_ll2_start_xmit()
2745 mapping = skb_frag_dma_map(&cdev->pdev->dev, frag, 0, in qed_ll2_start_xmit()
2748 if (unlikely(dma_mapping_error(&cdev->pdev->dev, mapping))) { in qed_ll2_start_xmit()
2750 "Unable to map frag - dropping packet\n"); in qed_ll2_start_xmit()
2751 rc = -ENOMEM; in qed_ll2_start_xmit()
2756 cdev->ll2->handle, in qed_ll2_start_xmit()
2770 dma_unmap_single(&cdev->pdev->dev, mapping, skb->len, DMA_TO_DEVICE); in qed_ll2_start_xmit()
2781 if (!cdev->ll2) in qed_ll2_stats()
2782 return -EINVAL; in qed_ll2_stats()
2784 rc = qed_ll2_get_stats(p_hwfn, cdev->ll2->handle, stats); in qed_ll2_stats()
2793 cdev->ll2->handle, stats); in qed_ll2_stats()
2814 cdev->ll2 = kzalloc(sizeof(*cdev->ll2), GFP_KERNEL); in qed_ll2_alloc_if()
2815 return cdev->ll2 ? 0 : -ENOMEM; in qed_ll2_alloc_if()
2820 kfree(cdev->ll2); in qed_ll2_dealloc_if()
2821 cdev->ll2 = NULL; in qed_ll2_dealloc_if()