1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
11 #include "tf_msg_common.h"
12 #include "tf_device.h"
15 #include "tf_common.h"
16 #include "tf_session.h"
22 * This is the MAX data we can transport across regular HWRM
24 #define TF_PCI_BUF_SIZE_MAX 88
27 * If data bigger than TF_PCI_BUF_SIZE_MAX then use DMA method
29 struct tf_msg_dma_buf {
35 * Allocates a DMA buffer that can be used for message transfer.
38 * Pointer to DMA buffer structure
41 * Requested size of the buffer in bytes
45 * -ENOMEM - Unable to allocate buffer, no memory
48 tf_msg_alloc_dma_buf(struct tf_msg_dma_buf *buf, int size)
50 struct tfp_calloc_parms alloc_parms;
53 /* Allocate session */
54 alloc_parms.nitems = 1;
55 alloc_parms.size = size;
56 alloc_parms.alignment = 4096;
57 rc = tfp_calloc(&alloc_parms);
61 buf->pa_addr = (uintptr_t)alloc_parms.mem_pa;
62 buf->va_addr = alloc_parms.mem_va;
68 * Free's a previous allocated DMA buffer.
71 * Pointer to DMA buffer structure
74 tf_msg_free_dma_buf(struct tf_msg_dma_buf *buf)
76 tfp_free(buf->va_addr);
79 /* HWRM Direct messages */
82 tf_msg_session_open(struct tf *tfp,
84 uint8_t *fw_session_id)
87 struct hwrm_tf_session_open_input req = { 0 };
88 struct hwrm_tf_session_open_output resp = { 0 };
89 struct tfp_send_msg_parms parms = { 0 };
91 /* Populate the request */
92 tfp_memcpy(&req.session_name, ctrl_chan_name, TF_SESSION_NAME_MAX);
94 parms.tf_type = HWRM_TF_SESSION_OPEN;
95 parms.req_data = (uint32_t *)&req;
96 parms.req_size = sizeof(req);
97 parms.resp_data = (uint32_t *)&resp;
98 parms.resp_size = sizeof(resp);
99 parms.mailbox = TF_KONG_MB;
101 rc = tfp_send_msg_direct(tfp,
106 *fw_session_id = resp.fw_session_id;
112 tf_msg_session_attach(struct tf *tfp __rte_unused,
113 char *ctrl_chan_name __rte_unused,
114 uint8_t tf_fw_session_id __rte_unused)
120 tf_msg_session_close(struct tf *tfp)
123 struct hwrm_tf_session_close_input req = { 0 };
124 struct hwrm_tf_session_close_output resp = { 0 };
125 struct tf_session *tfs = (struct tf_session *)(tfp->session->core_data);
126 struct tfp_send_msg_parms parms = { 0 };
128 /* Populate the request */
130 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
132 parms.tf_type = HWRM_TF_SESSION_CLOSE;
133 parms.req_data = (uint32_t *)&req;
134 parms.req_size = sizeof(req);
135 parms.resp_data = (uint32_t *)&resp;
136 parms.resp_size = sizeof(resp);
137 parms.mailbox = TF_KONG_MB;
139 rc = tfp_send_msg_direct(tfp,
145 tf_msg_session_qcfg(struct tf *tfp)
148 struct hwrm_tf_session_qcfg_input req = { 0 };
149 struct hwrm_tf_session_qcfg_output resp = { 0 };
150 struct tf_session *tfs = (struct tf_session *)(tfp->session->core_data);
151 struct tfp_send_msg_parms parms = { 0 };
153 /* Populate the request */
155 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
157 parms.tf_type = HWRM_TF_SESSION_QCFG,
158 parms.req_data = (uint32_t *)&req;
159 parms.req_size = sizeof(req);
160 parms.resp_data = (uint32_t *)&resp;
161 parms.resp_size = sizeof(resp);
162 parms.mailbox = TF_KONG_MB;
164 rc = tfp_send_msg_direct(tfp,
170 tf_msg_session_resc_qcaps(struct tf *tfp,
173 struct tf_rm_resc_req_entry *query,
174 enum tf_rm_resc_resv_strategy *resv_strategy)
178 struct tfp_send_msg_parms parms = { 0 };
179 struct hwrm_tf_session_resc_qcaps_input req = { 0 };
180 struct hwrm_tf_session_resc_qcaps_output resp = { 0 };
181 uint8_t fw_session_id;
182 struct tf_msg_dma_buf qcaps_buf = { 0 };
183 struct tf_rm_resc_req_entry *data;
186 TF_CHECK_PARMS3(tfp, query, resv_strategy);
188 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
191 "%s: Unable to lookup FW id, rc:%s\n",
197 /* Prepare DMA buffer */
198 dma_size = size * sizeof(struct tf_rm_resc_req_entry);
199 rc = tf_msg_alloc_dma_buf(&qcaps_buf, dma_size);
203 /* Populate the request */
204 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
205 req.flags = tfp_cpu_to_le_16(dir);
206 req.qcaps_size = size;
207 req.qcaps_addr = tfp_cpu_to_le_64(qcaps_buf.pa_addr);
209 parms.tf_type = HWRM_TF_SESSION_RESC_QCAPS;
210 parms.req_data = (uint32_t *)&req;
211 parms.req_size = sizeof(req);
212 parms.resp_data = (uint32_t *)&resp;
213 parms.resp_size = sizeof(resp);
214 parms.mailbox = TF_KONG_MB;
216 rc = tfp_send_msg_direct(tfp, &parms);
220 /* Process the response
221 * Should always get expected number of entries
223 if (tfp_le_to_cpu_32(resp.size) != size) {
225 "%s: QCAPS message size error, rc:%s\n",
231 printf("size: %d\n", tfp_le_to_cpu_32(resp.size));
233 /* Post process the response */
234 data = (struct tf_rm_resc_req_entry *)qcaps_buf.va_addr;
237 for (i = 0; i < size; i++) {
238 query[i].type = tfp_le_to_cpu_32(data[i].type);
239 query[i].min = tfp_le_to_cpu_16(data[i].min);
240 query[i].max = tfp_le_to_cpu_16(data[i].max);
242 printf("type: %d(0x%x) %d %d\n",
250 *resv_strategy = resp.flags &
251 HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_MASK;
253 tf_msg_free_dma_buf(&qcaps_buf);
259 tf_msg_session_resc_alloc(struct tf *tfp,
262 struct tf_rm_resc_req_entry *request,
263 struct tf_rm_resc_entry *resv)
267 struct tfp_send_msg_parms parms = { 0 };
268 struct hwrm_tf_session_resc_alloc_input req = { 0 };
269 struct hwrm_tf_session_resc_alloc_output resp = { 0 };
270 uint8_t fw_session_id;
271 struct tf_msg_dma_buf req_buf = { 0 };
272 struct tf_msg_dma_buf resv_buf = { 0 };
273 struct tf_rm_resc_req_entry *req_data;
274 struct tf_rm_resc_entry *resv_data;
277 TF_CHECK_PARMS3(tfp, request, resv);
279 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
282 "%s: Unable to lookup FW id, rc:%s\n",
288 /* Prepare DMA buffers */
289 dma_size = size * sizeof(struct tf_rm_resc_req_entry);
290 rc = tf_msg_alloc_dma_buf(&req_buf, dma_size);
294 dma_size = size * sizeof(struct tf_rm_resc_entry);
295 rc = tf_msg_alloc_dma_buf(&resv_buf, dma_size);
299 /* Populate the request */
300 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
301 req.flags = tfp_cpu_to_le_16(dir);
304 req_data = (struct tf_rm_resc_req_entry *)req_buf.va_addr;
305 for (i = 0; i < size; i++) {
306 req_data[i].type = tfp_cpu_to_le_32(request[i].type);
307 req_data[i].min = tfp_cpu_to_le_16(request[i].min);
308 req_data[i].max = tfp_cpu_to_le_16(request[i].max);
311 req.req_addr = tfp_cpu_to_le_64(req_buf.pa_addr);
312 req.resc_addr = tfp_cpu_to_le_64(resv_buf.pa_addr);
314 parms.tf_type = HWRM_TF_SESSION_RESC_ALLOC;
315 parms.req_data = (uint32_t *)&req;
316 parms.req_size = sizeof(req);
317 parms.resp_data = (uint32_t *)&resp;
318 parms.resp_size = sizeof(resp);
319 parms.mailbox = TF_KONG_MB;
321 rc = tfp_send_msg_direct(tfp, &parms);
325 /* Process the response
326 * Should always get expected number of entries
328 if (tfp_le_to_cpu_32(resp.size) != size) {
330 "%s: Alloc message size error, rc:%s\n",
337 printf("size: %d\n", tfp_le_to_cpu_32(resp.size));
339 /* Post process the response */
340 resv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr;
341 for (i = 0; i < size; i++) {
342 resv[i].type = tfp_le_to_cpu_32(resv_data[i].type);
343 resv[i].start = tfp_le_to_cpu_16(resv_data[i].start);
344 resv[i].stride = tfp_le_to_cpu_16(resv_data[i].stride);
346 printf("%d type: %d(0x%x) %d %d\n",
354 tf_msg_free_dma_buf(&req_buf);
355 tf_msg_free_dma_buf(&resv_buf);
361 tf_msg_session_resc_flush(struct tf *tfp,
364 struct tf_rm_resc_entry *resv)
368 struct tfp_send_msg_parms parms = { 0 };
369 struct hwrm_tf_session_resc_flush_input req = { 0 };
370 struct hwrm_tf_session_resc_flush_output resp = { 0 };
371 uint8_t fw_session_id;
372 struct tf_msg_dma_buf resv_buf = { 0 };
373 struct tf_rm_resc_entry *resv_data;
376 TF_CHECK_PARMS2(tfp, resv);
378 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
381 "%s: Unable to lookup FW id, rc:%s\n",
387 /* Prepare DMA buffers */
388 dma_size = size * sizeof(struct tf_rm_resc_entry);
389 rc = tf_msg_alloc_dma_buf(&resv_buf, dma_size);
393 /* Populate the request */
394 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
395 req.flags = tfp_cpu_to_le_16(dir);
396 req.flush_size = size;
398 resv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr;
399 for (i = 0; i < size; i++) {
400 resv_data[i].type = tfp_cpu_to_le_32(resv[i].type);
401 resv_data[i].start = tfp_cpu_to_le_16(resv[i].start);
402 resv_data[i].stride = tfp_cpu_to_le_16(resv[i].stride);
405 req.flush_addr = tfp_cpu_to_le_64(resv_buf.pa_addr);
407 parms.tf_type = HWRM_TF_SESSION_RESC_FLUSH;
408 parms.req_data = (uint32_t *)&req;
409 parms.req_size = sizeof(req);
410 parms.resp_data = (uint32_t *)&resp;
411 parms.resp_size = sizeof(resp);
412 parms.mailbox = TF_KONG_MB;
414 rc = tfp_send_msg_direct(tfp, &parms);
418 tf_msg_free_dma_buf(&resv_buf);
424 tf_msg_insert_em_internal_entry(struct tf *tfp,
425 struct tf_insert_em_entry_parms *em_parms,
426 uint16_t *rptr_index,
428 uint8_t *num_of_entries)
431 struct tfp_send_msg_parms parms = { 0 };
432 struct hwrm_tf_em_insert_input req = { 0 };
433 struct hwrm_tf_em_insert_output resp = { 0 };
434 struct tf_session *tfs = (struct tf_session *)(tfp->session->core_data);
435 struct tf_em_64b_entry *em_result =
436 (struct tf_em_64b_entry *)em_parms->em_record;
440 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
441 tfp_memcpy(req.em_key,
443 ((em_parms->key_sz_in_bits + 7) / 8));
445 flags = (em_parms->dir == TF_DIR_TX ?
446 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_TX :
447 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_RX);
448 req.flags = tfp_cpu_to_le_16(flags);
449 req.strength = (em_result->hdr.word1 &
450 CFA_P4_EEM_ENTRY_STRENGTH_MASK) >>
451 CFA_P4_EEM_ENTRY_STRENGTH_SHIFT;
452 req.em_key_bitlen = em_parms->key_sz_in_bits;
453 req.action_ptr = em_result->hdr.pointer;
454 req.em_record_idx = *rptr_index;
456 parms.tf_type = HWRM_TF_EM_INSERT;
457 parms.req_data = (uint32_t *)&req;
458 parms.req_size = sizeof(req);
459 parms.resp_data = (uint32_t *)&resp;
460 parms.resp_size = sizeof(resp);
461 parms.mailbox = TF_KONG_MB;
463 rc = tfp_send_msg_direct(tfp,
468 *rptr_entry = resp.rptr_entry;
469 *rptr_index = resp.rptr_index;
470 *num_of_entries = resp.num_of_entries;
476 tf_msg_delete_em_entry(struct tf *tfp,
477 struct tf_delete_em_entry_parms *em_parms)
480 struct tfp_send_msg_parms parms = { 0 };
481 struct hwrm_tf_em_delete_input req = { 0 };
482 struct hwrm_tf_em_delete_output resp = { 0 };
484 struct tf_session *tfs =
485 (struct tf_session *)(tfp->session->core_data);
488 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
490 flags = (em_parms->dir == TF_DIR_TX ?
491 HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_TX :
492 HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_RX);
493 req.flags = tfp_cpu_to_le_16(flags);
494 req.flow_handle = tfp_cpu_to_le_64(em_parms->flow_handle);
496 parms.tf_type = HWRM_TF_EM_DELETE;
497 parms.req_data = (uint32_t *)&req;
498 parms.req_size = sizeof(req);
499 parms.resp_data = (uint32_t *)&resp;
500 parms.resp_size = sizeof(resp);
501 parms.mailbox = TF_KONG_MB;
503 rc = tfp_send_msg_direct(tfp,
508 em_parms->index = tfp_le_to_cpu_16(resp.em_index);
514 tf_msg_em_mem_rgtr(struct tf *tfp,
521 struct hwrm_tf_ctxt_mem_rgtr_input req = { 0 };
522 struct hwrm_tf_ctxt_mem_rgtr_output resp = { 0 };
523 struct tfp_send_msg_parms parms = { 0 };
525 req.page_level = page_lvl;
526 req.page_size = page_size;
527 req.page_dir = tfp_cpu_to_le_64(dma_addr);
529 parms.tf_type = HWRM_TF_CTXT_MEM_RGTR;
530 parms.req_data = (uint32_t *)&req;
531 parms.req_size = sizeof(req);
532 parms.resp_data = (uint32_t *)&resp;
533 parms.resp_size = sizeof(resp);
534 parms.mailbox = TF_KONG_MB;
536 rc = tfp_send_msg_direct(tfp,
541 *ctx_id = tfp_le_to_cpu_16(resp.ctx_id);
547 tf_msg_em_mem_unrgtr(struct tf *tfp,
551 struct hwrm_tf_ctxt_mem_unrgtr_input req = {0};
552 struct hwrm_tf_ctxt_mem_unrgtr_output resp = {0};
553 struct tfp_send_msg_parms parms = { 0 };
555 req.ctx_id = tfp_cpu_to_le_32(*ctx_id);
557 parms.tf_type = HWRM_TF_CTXT_MEM_UNRGTR;
558 parms.req_data = (uint32_t *)&req;
559 parms.req_size = sizeof(req);
560 parms.resp_data = (uint32_t *)&resp;
561 parms.resp_size = sizeof(resp);
562 parms.mailbox = TF_KONG_MB;
564 rc = tfp_send_msg_direct(tfp,
570 tf_msg_em_qcaps(struct tf *tfp,
572 struct tf_em_caps *em_caps)
575 struct hwrm_tf_ext_em_qcaps_input req = {0};
576 struct hwrm_tf_ext_em_qcaps_output resp = { 0 };
578 struct tfp_send_msg_parms parms = { 0 };
580 flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_TX :
581 HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_RX);
582 req.flags = tfp_cpu_to_le_32(flags);
584 parms.tf_type = HWRM_TF_EXT_EM_QCAPS;
585 parms.req_data = (uint32_t *)&req;
586 parms.req_size = sizeof(req);
587 parms.resp_data = (uint32_t *)&resp;
588 parms.resp_size = sizeof(resp);
589 parms.mailbox = TF_KONG_MB;
591 rc = tfp_send_msg_direct(tfp,
596 em_caps->supported = tfp_le_to_cpu_32(resp.supported);
597 em_caps->max_entries_supported =
598 tfp_le_to_cpu_32(resp.max_entries_supported);
599 em_caps->key_entry_size = tfp_le_to_cpu_16(resp.key_entry_size);
600 em_caps->record_entry_size =
601 tfp_le_to_cpu_16(resp.record_entry_size);
602 em_caps->efc_entry_size = tfp_le_to_cpu_16(resp.efc_entry_size);
608 tf_msg_em_cfg(struct tf *tfp,
609 uint32_t num_entries,
610 uint16_t key0_ctx_id,
611 uint16_t key1_ctx_id,
612 uint16_t record_ctx_id,
614 uint8_t flush_interval,
618 struct hwrm_tf_ext_em_cfg_input req = {0};
619 struct hwrm_tf_ext_em_cfg_output resp = {0};
621 struct tfp_send_msg_parms parms = { 0 };
623 flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX :
624 HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX);
625 flags |= HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_PREFERRED_OFFLOAD;
627 req.flags = tfp_cpu_to_le_32(flags);
628 req.num_entries = tfp_cpu_to_le_32(num_entries);
630 req.flush_interval = flush_interval;
632 req.key0_ctx_id = tfp_cpu_to_le_16(key0_ctx_id);
633 req.key1_ctx_id = tfp_cpu_to_le_16(key1_ctx_id);
634 req.record_ctx_id = tfp_cpu_to_le_16(record_ctx_id);
635 req.efc_ctx_id = tfp_cpu_to_le_16(efc_ctx_id);
637 parms.tf_type = HWRM_TF_EXT_EM_CFG;
638 parms.req_data = (uint32_t *)&req;
639 parms.req_size = sizeof(req);
640 parms.resp_data = (uint32_t *)&resp;
641 parms.resp_size = sizeof(resp);
642 parms.mailbox = TF_KONG_MB;
644 rc = tfp_send_msg_direct(tfp,
650 tf_msg_em_op(struct tf *tfp,
655 struct hwrm_tf_ext_em_op_input req = {0};
656 struct hwrm_tf_ext_em_op_output resp = {0};
658 struct tfp_send_msg_parms parms = { 0 };
660 flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX :
661 HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX);
662 req.flags = tfp_cpu_to_le_32(flags);
663 req.op = tfp_cpu_to_le_16(op);
665 parms.tf_type = HWRM_TF_EXT_EM_OP;
666 parms.req_data = (uint32_t *)&req;
667 parms.req_size = sizeof(req);
668 parms.resp_data = (uint32_t *)&resp;
669 parms.resp_size = sizeof(resp);
670 parms.mailbox = TF_KONG_MB;
672 rc = tfp_send_msg_direct(tfp,
678 tf_msg_tcam_entry_set(struct tf *tfp,
679 struct tf_tcam_set_parms *parms)
682 struct tfp_send_msg_parms mparms = { 0 };
683 struct hwrm_tf_tcam_set_input req = { 0 };
684 struct hwrm_tf_tcam_set_output resp = { 0 };
685 struct tf_msg_dma_buf buf = { 0 };
686 uint8_t *data = NULL;
689 req.type = parms->hcapi_type;
690 req.idx = tfp_cpu_to_le_16(parms->idx);
691 if (parms->dir == TF_DIR_TX)
692 req.flags |= HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR_TX;
694 req.key_size = parms->key_size;
695 req.mask_offset = parms->key_size;
696 /* Result follows after key and mask, thus multiply by 2 */
697 req.result_offset = 2 * parms->key_size;
698 req.result_size = parms->result_size;
699 data_size = 2 * req.key_size + req.result_size;
701 if (data_size <= TF_PCI_BUF_SIZE_MAX) {
703 data = &req.dev_data[0];
706 req.flags |= HWRM_TF_TCAM_SET_INPUT_FLAGS_DMA;
707 rc = tf_msg_alloc_dma_buf(&buf, data_size);
711 tfp_memcpy(&req.dev_data[0],
713 sizeof(buf.pa_addr));
716 tfp_memcpy(&data[0], parms->key, parms->key_size);
717 tfp_memcpy(&data[parms->key_size], parms->mask, parms->key_size);
718 tfp_memcpy(&data[req.result_offset], parms->result, parms->result_size);
720 mparms.tf_type = HWRM_TF_TCAM_SET;
721 mparms.req_data = (uint32_t *)&req;
722 mparms.req_size = sizeof(req);
723 mparms.resp_data = (uint32_t *)&resp;
724 mparms.resp_size = sizeof(resp);
725 mparms.mailbox = TF_KONG_MB;
727 rc = tfp_send_msg_direct(tfp,
733 tf_msg_free_dma_buf(&buf);
739 tf_msg_tcam_entry_free(struct tf *tfp,
740 struct tf_tcam_free_parms *in_parms)
743 struct hwrm_tf_tcam_free_input req = { 0 };
744 struct hwrm_tf_tcam_free_output resp = { 0 };
745 struct tfp_send_msg_parms parms = { 0 };
747 req.type = in_parms->hcapi_type;
749 req.idx_list[0] = tfp_cpu_to_le_16(in_parms->idx);
750 if (in_parms->dir == TF_DIR_TX)
751 req.flags |= HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR_TX;
753 parms.tf_type = HWRM_TF_TCAM_FREE;
754 parms.req_data = (uint32_t *)&req;
755 parms.req_size = sizeof(req);
756 parms.resp_data = (uint32_t *)&resp;
757 parms.resp_size = sizeof(resp);
758 parms.mailbox = TF_KONG_MB;
760 rc = tfp_send_msg_direct(tfp,
766 tf_msg_set_tbl_entry(struct tf *tfp,
774 struct hwrm_tf_tbl_type_set_input req = { 0 };
775 struct hwrm_tf_tbl_type_set_output resp = { 0 };
776 struct tfp_send_msg_parms parms = { 0 };
777 struct tf_session *tfs;
779 /* Retrieve the session information */
780 rc = tf_session_get_session(tfp, &tfs);
783 "%s: Failed to lookup session, rc:%s\n",
789 /* Populate the request */
791 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
792 req.flags = tfp_cpu_to_le_16(dir);
793 req.type = tfp_cpu_to_le_32(hcapi_type);
794 req.size = tfp_cpu_to_le_16(size);
795 req.index = tfp_cpu_to_le_32(index);
797 tfp_memcpy(&req.data,
801 parms.tf_type = HWRM_TF_TBL_TYPE_SET;
802 parms.req_data = (uint32_t *)&req;
803 parms.req_size = sizeof(req);
804 parms.resp_data = (uint32_t *)&resp;
805 parms.resp_size = sizeof(resp);
806 parms.mailbox = TF_KONG_MB;
808 rc = tfp_send_msg_direct(tfp,
813 return tfp_le_to_cpu_32(parms.tf_resp_code);
817 tf_msg_get_tbl_entry(struct tf *tfp,
825 struct hwrm_tf_tbl_type_get_input req = { 0 };
826 struct hwrm_tf_tbl_type_get_output resp = { 0 };
827 struct tfp_send_msg_parms parms = { 0 };
828 struct tf_session *tfs;
830 /* Retrieve the session information */
831 rc = tf_session_get_session(tfp, &tfs);
834 "%s: Failed to lookup session, rc:%s\n",
840 /* Populate the request */
842 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
843 req.flags = tfp_cpu_to_le_16(dir);
844 req.type = tfp_cpu_to_le_32(hcapi_type);
845 req.index = tfp_cpu_to_le_32(index);
847 parms.tf_type = HWRM_TF_TBL_TYPE_GET;
848 parms.req_data = (uint32_t *)&req;
849 parms.req_size = sizeof(req);
850 parms.resp_data = (uint32_t *)&resp;
851 parms.resp_size = sizeof(resp);
852 parms.mailbox = TF_KONG_MB;
854 rc = tfp_send_msg_direct(tfp,
859 /* Verify that we got enough buffer to return the requested data */
860 if (resp.size < size)
867 return tfp_le_to_cpu_32(parms.tf_resp_code);
870 /* HWRM Tunneled messages */
873 tf_msg_bulk_get_tbl_entry(struct tf *tfp,
874 struct tf_bulk_get_tbl_entry_parms *params)
877 struct tfp_send_msg_parms parms = { 0 };
878 struct tf_tbl_type_bulk_get_input req = { 0 };
879 struct tf_tbl_type_bulk_get_output resp = { 0 };
880 struct tf_session *tfs = (struct tf_session *)(tfp->session->core_data);
883 /* Populate the request */
885 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
886 req.flags = tfp_cpu_to_le_16(params->dir);
887 req.type = tfp_cpu_to_le_32(params->type);
888 req.start_index = tfp_cpu_to_le_32(params->starting_idx);
889 req.num_entries = tfp_cpu_to_le_32(params->num_entries);
891 data_size = params->num_entries * params->entry_sz_in_bytes;
893 req.host_addr = tfp_cpu_to_le_64(params->physical_mem_addr);
898 HWRM_TFT_TBL_TYPE_BULK_GET,
902 rc = tfp_send_msg_tunneled(tfp, &parms);
906 /* Verify that we got enough buffer to return the requested data */
907 if (resp.size < data_size)
910 return tfp_le_to_cpu_32(parms.tf_resp_code);