1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
12 #include "tf_msg_common.h"
13 #include "tf_device.h"
16 #include "tf_common.h"
17 #include "tf_session.h"
22 /* Specific msg size defines as we cannot use defines in tf.yaml. This
23 * means we have to manually sync hwrm with these defines if the
26 #define TF_MSG_SET_GLOBAL_CFG_DATA_SIZE 16
27 #define TF_MSG_EM_INSERT_KEY_SIZE 64
28 #define TF_MSG_EM_INSERT_RECORD_SIZE 80
29 #define TF_MSG_TBL_TYPE_SET_DATA_SIZE 88
31 /* Compile check - Catch any msg changes that we depend on, like the
32 * defines listed above for array size checking.
34 * Checking array size is dangerous in that the type could change and
35 * we wouldn't be able to catch it. Thus we check if the complete msg
36 * changed instead. Best we can do.
38 * If failure is observed then both msg size (defines below) and the
39 * array size (define above) should be checked and compared.
41 #define TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET 56
42 static_assert(sizeof(struct hwrm_tf_global_cfg_set_input) ==
43 TF_MSG_SIZE_HWRM_TF_GLOBAL_CFG_SET,
44 "HWRM message size changed: hwrm_tf_global_cfg_set_input");
46 #define TF_MSG_SIZE_HWRM_TF_EM_INSERT 104
47 static_assert(sizeof(struct hwrm_tf_em_insert_input) ==
48 TF_MSG_SIZE_HWRM_TF_EM_INSERT,
49 "HWRM message size changed: hwrm_tf_em_insert_input");
51 #define TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET 128
52 static_assert(sizeof(struct hwrm_tf_tbl_type_set_input) ==
53 TF_MSG_SIZE_HWRM_TF_TBL_TYPE_SET,
54 "HWRM message size changed: hwrm_tf_tbl_type_set_input");
57 * This is the MAX data we can transport across regular HWRM
59 #define TF_PCI_BUF_SIZE_MAX 88
62 * If data bigger than TF_PCI_BUF_SIZE_MAX then use DMA method
64 struct tf_msg_dma_buf {
70 * Allocates a DMA buffer that can be used for message transfer.
73 * Pointer to DMA buffer structure
76 * Requested size of the buffer in bytes
80 * -ENOMEM - Unable to allocate buffer, no memory
83 tf_msg_alloc_dma_buf(struct tf_msg_dma_buf *buf, int size)
85 struct tfp_calloc_parms alloc_parms;
88 /* Allocate session */
89 alloc_parms.nitems = 1;
90 alloc_parms.size = size;
91 alloc_parms.alignment = 4096;
92 rc = tfp_calloc(&alloc_parms);
96 buf->pa_addr = (uintptr_t)alloc_parms.mem_pa;
97 buf->va_addr = alloc_parms.mem_va;
103 * Free's a previous allocated DMA buffer.
106 * Pointer to DMA buffer structure
109 tf_msg_free_dma_buf(struct tf_msg_dma_buf *buf)
111 tfp_free(buf->va_addr);
114 /* HWRM Direct messages */
117 tf_msg_session_open(struct tf *tfp,
118 char *ctrl_chan_name,
119 uint8_t *fw_session_id,
120 uint8_t *fw_session_client_id,
121 struct tf_dev_info *dev)
124 struct hwrm_tf_session_open_input req = { 0 };
125 struct hwrm_tf_session_open_output resp = { 0 };
126 struct tfp_send_msg_parms parms = { 0 };
128 /* Populate the request */
129 tfp_memcpy(&req.session_name, ctrl_chan_name, TF_SESSION_NAME_MAX);
131 parms.tf_type = HWRM_TF_SESSION_OPEN;
132 parms.req_data = (uint32_t *)&req;
133 parms.req_size = sizeof(req);
134 parms.resp_data = (uint32_t *)&resp;
135 parms.resp_size = sizeof(resp);
136 parms.mailbox = dev->ops->tf_dev_get_mailbox();
138 rc = tfp_send_msg_direct(tfp,
143 *fw_session_id = (uint8_t)tfp_le_to_cpu_32(resp.fw_session_id);
144 *fw_session_client_id =
145 (uint8_t)tfp_le_to_cpu_32(resp.fw_session_client_id);
151 tf_msg_session_attach(struct tf *tfp __rte_unused,
152 char *ctrl_chan_name __rte_unused,
153 uint8_t tf_fw_session_id __rte_unused)
159 tf_msg_session_client_register(struct tf *tfp,
160 struct tf_session *tfs,
161 char *ctrl_channel_name,
162 uint8_t *fw_session_client_id)
165 struct hwrm_tf_session_register_input req = { 0 };
166 struct hwrm_tf_session_register_output resp = { 0 };
167 struct tfp_send_msg_parms parms = { 0 };
168 uint8_t fw_session_id;
169 struct tf_dev_info *dev;
171 /* Retrieve the device information */
172 rc = tf_session_get_device(tfs, &dev);
175 "Failed to lookup device, rc:%s\n",
180 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
183 "Unable to lookup FW id, rc:%s\n",
188 /* Populate the request */
189 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
190 tfp_memcpy(&req.session_client_name,
192 TF_SESSION_NAME_MAX);
194 parms.tf_type = HWRM_TF_SESSION_REGISTER;
195 parms.req_data = (uint32_t *)&req;
196 parms.req_size = sizeof(req);
197 parms.resp_data = (uint32_t *)&resp;
198 parms.resp_size = sizeof(resp);
199 parms.mailbox = dev->ops->tf_dev_get_mailbox();
201 rc = tfp_send_msg_direct(tfp,
206 *fw_session_client_id =
207 (uint8_t)tfp_le_to_cpu_32(resp.fw_session_client_id);
213 tf_msg_session_client_unregister(struct tf *tfp,
214 struct tf_session *tfs,
215 uint8_t fw_session_client_id)
218 struct hwrm_tf_session_unregister_input req = { 0 };
219 struct hwrm_tf_session_unregister_output resp = { 0 };
220 struct tfp_send_msg_parms parms = { 0 };
221 uint8_t fw_session_id;
222 struct tf_dev_info *dev;
224 /* Retrieve the device information */
225 rc = tf_session_get_device(tfs, &dev);
228 "Failed to lookup device, rc:%s\n",
233 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
236 "Unable to lookup FW id, rc:%s\n",
241 /* Populate the request */
242 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
243 req.fw_session_client_id = tfp_cpu_to_le_32(fw_session_client_id);
245 parms.tf_type = HWRM_TF_SESSION_UNREGISTER;
246 parms.req_data = (uint32_t *)&req;
247 parms.req_size = sizeof(req);
248 parms.resp_data = (uint32_t *)&resp;
249 parms.resp_size = sizeof(resp);
250 parms.mailbox = dev->ops->tf_dev_get_mailbox();
252 rc = tfp_send_msg_direct(tfp,
259 tf_msg_session_close(struct tf *tfp,
260 struct tf_session *tfs)
263 struct hwrm_tf_session_close_input req = { 0 };
264 struct hwrm_tf_session_close_output resp = { 0 };
265 struct tfp_send_msg_parms parms = { 0 };
266 uint8_t fw_session_id;
267 struct tf_dev_info *dev;
269 /* Retrieve the device information */
270 rc = tf_session_get_device(tfs, &dev);
273 "Failed to lookup device, rc:%s\n",
278 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
281 "Unable to lookup FW id, rc:%s\n",
286 /* Populate the request */
287 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
289 parms.tf_type = HWRM_TF_SESSION_CLOSE;
290 parms.req_data = (uint32_t *)&req;
291 parms.req_size = sizeof(req);
292 parms.resp_data = (uint32_t *)&resp;
293 parms.resp_size = sizeof(resp);
294 parms.mailbox = dev->ops->tf_dev_get_mailbox();
296 rc = tfp_send_msg_direct(tfp,
302 tf_msg_session_qcfg(struct tf *tfp)
305 struct hwrm_tf_session_qcfg_input req = { 0 };
306 struct hwrm_tf_session_qcfg_output resp = { 0 };
307 struct tfp_send_msg_parms parms = { 0 };
308 uint8_t fw_session_id;
309 struct tf_dev_info *dev;
310 struct tf_session *tfs;
312 /* Retrieve the session information */
313 rc = tf_session_get_session_internal(tfp, &tfs);
316 "Failed to lookup session, rc:%s\n",
321 /* Retrieve the device information */
322 rc = tf_session_get_device(tfs, &dev);
325 "Failed to lookup device, rc:%s\n",
330 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
333 "Unable to lookup FW id, rc:%s\n",
338 /* Populate the request */
339 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
341 parms.tf_type = HWRM_TF_SESSION_QCFG,
342 parms.req_data = (uint32_t *)&req;
343 parms.req_size = sizeof(req);
344 parms.resp_data = (uint32_t *)&resp;
345 parms.resp_size = sizeof(resp);
346 parms.mailbox = dev->ops->tf_dev_get_mailbox();
348 rc = tfp_send_msg_direct(tfp,
354 tf_msg_session_resc_qcaps(struct tf *tfp,
355 struct tf_dev_info *dev,
358 struct tf_rm_resc_req_entry *query,
359 enum tf_rm_resc_resv_strategy *resv_strategy)
363 struct tfp_send_msg_parms parms = { 0 };
364 struct hwrm_tf_session_resc_qcaps_input req = { 0 };
365 struct hwrm_tf_session_resc_qcaps_output resp = { 0 };
366 uint8_t fw_session_id;
367 struct tf_msg_dma_buf qcaps_buf = { 0 };
368 struct tf_rm_resc_req_entry *data;
371 TF_CHECK_PARMS3(tfp, query, resv_strategy);
373 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
376 "%s: Unable to lookup FW id, rc:%s\n",
382 /* Prepare DMA buffer */
383 dma_size = size * sizeof(struct tf_rm_resc_req_entry);
384 rc = tf_msg_alloc_dma_buf(&qcaps_buf, dma_size);
388 /* Populate the request */
389 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
390 req.flags = tfp_cpu_to_le_16(dir);
391 req.qcaps_size = size;
392 req.qcaps_addr = tfp_cpu_to_le_64(qcaps_buf.pa_addr);
394 parms.tf_type = HWRM_TF_SESSION_RESC_QCAPS;
395 parms.req_data = (uint32_t *)&req;
396 parms.req_size = sizeof(req);
397 parms.resp_data = (uint32_t *)&resp;
398 parms.resp_size = sizeof(resp);
399 parms.mailbox = dev->ops->tf_dev_get_mailbox();
401 rc = tfp_send_msg_direct(tfp, &parms);
405 /* Process the response
406 * Should always get expected number of entries
408 if (tfp_le_to_cpu_32(resp.size) != size) {
410 "%s: QCAPS message size error, rc:%s\n",
417 /* Post process the response */
418 data = (struct tf_rm_resc_req_entry *)qcaps_buf.va_addr;
419 for (i = 0; i < size; i++) {
420 query[i].type = tfp_le_to_cpu_32(data[i].type);
421 query[i].min = tfp_le_to_cpu_16(data[i].min);
422 query[i].max = tfp_le_to_cpu_16(data[i].max);
425 *resv_strategy = resp.flags &
426 HWRM_TF_SESSION_RESC_QCAPS_OUTPUT_FLAGS_SESS_RESV_STRATEGY_MASK;
429 tf_msg_free_dma_buf(&qcaps_buf);
435 tf_msg_session_resc_alloc(struct tf *tfp,
436 struct tf_dev_info *dev,
439 struct tf_rm_resc_req_entry *request,
440 struct tf_rm_resc_entry *resv)
444 struct tfp_send_msg_parms parms = { 0 };
445 struct hwrm_tf_session_resc_alloc_input req = { 0 };
446 struct hwrm_tf_session_resc_alloc_output resp = { 0 };
447 uint8_t fw_session_id;
448 struct tf_msg_dma_buf req_buf = { 0 };
449 struct tf_msg_dma_buf resv_buf = { 0 };
450 struct tf_rm_resc_req_entry *req_data;
451 struct tf_rm_resc_entry *resv_data;
454 TF_CHECK_PARMS3(tfp, request, resv);
456 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
459 "%s: Unable to lookup FW id, rc:%s\n",
465 /* Prepare DMA buffers */
466 dma_size = size * sizeof(struct tf_rm_resc_req_entry);
467 rc = tf_msg_alloc_dma_buf(&req_buf, dma_size);
471 dma_size = size * sizeof(struct tf_rm_resc_entry);
472 rc = tf_msg_alloc_dma_buf(&resv_buf, dma_size);
474 tf_msg_free_dma_buf(&req_buf);
478 /* Populate the request */
479 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
480 req.flags = tfp_cpu_to_le_16(dir);
483 req_data = (struct tf_rm_resc_req_entry *)req_buf.va_addr;
484 for (i = 0; i < size; i++) {
485 req_data[i].type = tfp_cpu_to_le_32(request[i].type);
486 req_data[i].min = tfp_cpu_to_le_16(request[i].min);
487 req_data[i].max = tfp_cpu_to_le_16(request[i].max);
490 req.req_addr = tfp_cpu_to_le_64(req_buf.pa_addr);
491 req.resc_addr = tfp_cpu_to_le_64(resv_buf.pa_addr);
493 parms.tf_type = HWRM_TF_SESSION_RESC_ALLOC;
494 parms.req_data = (uint32_t *)&req;
495 parms.req_size = sizeof(req);
496 parms.resp_data = (uint32_t *)&resp;
497 parms.resp_size = sizeof(resp);
498 parms.mailbox = dev->ops->tf_dev_get_mailbox();
500 rc = tfp_send_msg_direct(tfp, &parms);
504 /* Process the response
505 * Should always get expected number of entries
507 if (tfp_le_to_cpu_32(resp.size) != size) {
509 "%s: Alloc message size error, rc:%s\n",
516 /* Post process the response */
517 resv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr;
518 for (i = 0; i < size; i++) {
519 resv[i].type = tfp_le_to_cpu_32(resv_data[i].type);
520 resv[i].start = tfp_le_to_cpu_16(resv_data[i].start);
521 resv[i].stride = tfp_le_to_cpu_16(resv_data[i].stride);
525 tf_msg_free_dma_buf(&req_buf);
526 tf_msg_free_dma_buf(&resv_buf);
532 tf_msg_session_resc_flush(struct tf *tfp,
535 struct tf_rm_resc_entry *resv)
539 struct tfp_send_msg_parms parms = { 0 };
540 struct hwrm_tf_session_resc_flush_input req = { 0 };
541 struct hwrm_tf_session_resc_flush_output resp = { 0 };
542 uint8_t fw_session_id;
543 struct tf_msg_dma_buf resv_buf = { 0 };
544 struct tf_rm_resc_entry *resv_data;
546 struct tf_dev_info *dev;
547 struct tf_session *tfs;
549 TF_CHECK_PARMS2(tfp, resv);
551 /* Retrieve the session information */
552 rc = tf_session_get_session_internal(tfp, &tfs);
555 "%s: Failed to lookup session, rc:%s\n",
561 /* Retrieve the device information */
562 rc = tf_session_get_device(tfs, &dev);
565 "%s: Failed to lookup device, rc:%s\n",
571 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
574 "%s: Unable to lookup FW id, rc:%s\n",
580 /* Prepare DMA buffers */
581 dma_size = size * sizeof(struct tf_rm_resc_entry);
582 rc = tf_msg_alloc_dma_buf(&resv_buf, dma_size);
586 /* Populate the request */
587 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
588 req.flags = tfp_cpu_to_le_16(dir);
589 req.flush_size = size;
591 resv_data = (struct tf_rm_resc_entry *)resv_buf.va_addr;
592 for (i = 0; i < size; i++) {
593 resv_data[i].type = tfp_cpu_to_le_32(resv[i].type);
594 resv_data[i].start = tfp_cpu_to_le_16(resv[i].start);
595 resv_data[i].stride = tfp_cpu_to_le_16(resv[i].stride);
598 req.flush_addr = tfp_cpu_to_le_64(resv_buf.pa_addr);
600 parms.tf_type = HWRM_TF_SESSION_RESC_FLUSH;
601 parms.req_data = (uint32_t *)&req;
602 parms.req_size = sizeof(req);
603 parms.resp_data = (uint32_t *)&resp;
604 parms.resp_size = sizeof(resp);
605 parms.mailbox = dev->ops->tf_dev_get_mailbox();
607 rc = tfp_send_msg_direct(tfp, &parms);
609 tf_msg_free_dma_buf(&resv_buf);
615 tf_msg_insert_em_internal_entry(struct tf *tfp,
616 struct tf_insert_em_entry_parms *em_parms,
617 uint16_t *rptr_index,
619 uint8_t *num_of_entries)
622 struct tfp_send_msg_parms parms = { 0 };
623 struct hwrm_tf_em_insert_input req = { 0 };
624 struct hwrm_tf_em_insert_output resp = { 0 };
625 struct tf_em_64b_entry *em_result =
626 (struct tf_em_64b_entry *)em_parms->em_record;
628 uint8_t fw_session_id;
629 uint8_t msg_key_size;
630 struct tf_dev_info *dev;
631 struct tf_session *tfs;
633 /* Retrieve the session information */
634 rc = tf_session_get_session_internal(tfp, &tfs);
637 "%s: Failed to lookup session, rc:%s\n",
638 tf_dir_2_str(em_parms->dir),
643 /* Retrieve the device information */
644 rc = tf_session_get_device(tfs, &dev);
647 "%s: Failed to lookup device, rc:%s\n",
648 tf_dir_2_str(em_parms->dir),
653 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
656 "%s: Unable to lookup FW id, rc:%s\n",
657 tf_dir_2_str(em_parms->dir),
662 /* Populate the request */
663 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
665 /* Check for key size conformity */
666 msg_key_size = (em_parms->key_sz_in_bits + 7) / 8;
667 if (msg_key_size > TF_MSG_EM_INSERT_KEY_SIZE) {
670 "%s: Invalid parameters for msg type, rc:%s\n",
671 tf_dir_2_str(em_parms->dir),
676 tfp_memcpy(req.em_key,
680 flags = (em_parms->dir == TF_DIR_TX ?
681 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_TX :
682 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_RX);
683 req.flags = tfp_cpu_to_le_16(flags);
684 req.strength = (em_result->hdr.word1 &
685 CFA_P4_EEM_ENTRY_STRENGTH_MASK) >>
686 CFA_P4_EEM_ENTRY_STRENGTH_SHIFT;
687 req.em_key_bitlen = em_parms->key_sz_in_bits;
688 req.action_ptr = em_result->hdr.pointer;
689 req.em_record_idx = *rptr_index;
691 parms.tf_type = HWRM_TF_EM_INSERT;
692 parms.req_data = (uint32_t *)&req;
693 parms.req_size = sizeof(req);
694 parms.resp_data = (uint32_t *)&resp;
695 parms.resp_size = sizeof(resp);
696 parms.mailbox = dev->ops->tf_dev_get_mailbox();
698 rc = tfp_send_msg_direct(tfp,
703 *rptr_entry = resp.rptr_entry;
704 *rptr_index = resp.rptr_index;
705 *num_of_entries = resp.num_of_entries;
711 tf_msg_hash_insert_em_internal_entry(struct tf *tfp,
712 struct tf_insert_em_entry_parms *em_parms,
715 uint16_t *rptr_index,
717 uint8_t *num_of_entries)
720 struct tfp_send_msg_parms parms = { 0 };
721 struct hwrm_tf_em_hash_insert_input req = { 0 };
722 struct hwrm_tf_em_hash_insert_output resp = { 0 };
724 uint8_t fw_session_id;
725 uint8_t msg_record_size;
726 struct tf_dev_info *dev;
727 struct tf_session *tfs;
729 /* Retrieve the session information */
730 rc = tf_session_get_session_internal(tfp, &tfs);
733 "%s: Failed to lookup session, rc:%s\n",
734 tf_dir_2_str(em_parms->dir),
739 /* Retrieve the device information */
740 rc = tf_session_get_device(tfs, &dev);
743 "%s: Failed to lookup device, rc:%s\n",
744 tf_dir_2_str(em_parms->dir),
749 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
752 "%s: Unable to lookup FW id, rc:%s\n",
753 tf_dir_2_str(em_parms->dir),
758 /* Populate the request */
759 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
761 /* Check for key size conformity */
762 msg_record_size = (em_parms->em_record_sz_in_bits + 7) / 8;
764 if (msg_record_size > TF_MSG_EM_INSERT_RECORD_SIZE) {
767 "%s: Record size to large, rc:%s\n",
768 tf_dir_2_str(em_parms->dir),
773 tfp_memcpy((char *)req.em_record,
777 flags = (em_parms->dir == TF_DIR_TX ?
778 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_TX :
779 HWRM_TF_EM_INSERT_INPUT_FLAGS_DIR_RX);
780 req.flags = tfp_cpu_to_le_16(flags);
781 req.em_record_size_bits = em_parms->em_record_sz_in_bits;
782 req.em_record_idx = *rptr_index;
783 req.key0_hash = key0_hash;
784 req.key1_hash = key1_hash;
786 parms.tf_type = HWRM_TF_EM_HASH_INSERT;
787 parms.req_data = (uint32_t *)&req;
788 parms.req_size = sizeof(req);
789 parms.resp_data = (uint32_t *)&resp;
790 parms.resp_size = sizeof(resp);
791 parms.mailbox = dev->ops->tf_dev_get_mailbox();
793 rc = tfp_send_msg_direct(tfp,
798 *rptr_entry = resp.rptr_entry;
799 *rptr_index = resp.rptr_index;
800 *num_of_entries = resp.num_of_entries;
806 tf_msg_delete_em_entry(struct tf *tfp,
807 struct tf_delete_em_entry_parms *em_parms)
810 struct tfp_send_msg_parms parms = { 0 };
811 struct hwrm_tf_em_delete_input req = { 0 };
812 struct hwrm_tf_em_delete_output resp = { 0 };
814 uint8_t fw_session_id;
815 struct tf_dev_info *dev;
816 struct tf_session *tfs;
818 /* Retrieve the session information */
819 rc = tf_session_get_session_internal(tfp, &tfs);
822 "%s: Failed to lookup session, rc:%s\n",
823 tf_dir_2_str(em_parms->dir),
828 /* Retrieve the device information */
829 rc = tf_session_get_device(tfs, &dev);
832 "%s: Failed to lookup device, rc:%s\n",
833 tf_dir_2_str(em_parms->dir),
838 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
841 "%s: Unable to lookup FW id, rc:%s\n",
842 tf_dir_2_str(em_parms->dir),
847 /* Populate the request */
848 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
850 flags = (em_parms->dir == TF_DIR_TX ?
851 HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_TX :
852 HWRM_TF_EM_DELETE_INPUT_FLAGS_DIR_RX);
853 req.flags = tfp_cpu_to_le_16(flags);
854 req.flow_handle = tfp_cpu_to_le_64(em_parms->flow_handle);
856 parms.tf_type = HWRM_TF_EM_DELETE;
857 parms.req_data = (uint32_t *)&req;
858 parms.req_size = sizeof(req);
859 parms.resp_data = (uint32_t *)&resp;
860 parms.resp_size = sizeof(resp);
861 parms.mailbox = dev->ops->tf_dev_get_mailbox();
863 rc = tfp_send_msg_direct(tfp,
868 em_parms->index = tfp_le_to_cpu_16(resp.em_index);
874 tf_msg_em_mem_rgtr(struct tf *tfp,
881 struct hwrm_tf_ctxt_mem_rgtr_input req = { 0 };
882 struct hwrm_tf_ctxt_mem_rgtr_output resp = { 0 };
883 struct tfp_send_msg_parms parms = { 0 };
884 struct tf_dev_info *dev;
885 struct tf_session *tfs;
887 /* Retrieve the session information */
888 rc = tf_session_get_session_internal(tfp, &tfs);
891 "Failed to lookup session, rc:%s\n",
896 /* Retrieve the device information */
897 rc = tf_session_get_device(tfs, &dev);
900 "Failed to lookup device, rc:%s\n",
905 req.page_level = page_lvl;
906 req.page_size = page_size;
907 req.page_dir = tfp_cpu_to_le_64(dma_addr);
909 parms.tf_type = HWRM_TF_CTXT_MEM_RGTR;
910 parms.req_data = (uint32_t *)&req;
911 parms.req_size = sizeof(req);
912 parms.resp_data = (uint32_t *)&resp;
913 parms.resp_size = sizeof(resp);
914 parms.mailbox = dev->ops->tf_dev_get_mailbox();
916 rc = tfp_send_msg_direct(tfp,
921 *ctx_id = tfp_le_to_cpu_16(resp.ctx_id);
927 tf_msg_em_mem_unrgtr(struct tf *tfp,
931 struct hwrm_tf_ctxt_mem_unrgtr_input req = {0};
932 struct hwrm_tf_ctxt_mem_unrgtr_output resp = {0};
933 struct tfp_send_msg_parms parms = { 0 };
934 struct tf_dev_info *dev;
935 struct tf_session *tfs;
937 /* Retrieve the session information */
938 rc = tf_session_get_session_internal(tfp, &tfs);
941 "Failed to lookup session, rc:%s\n",
946 /* Retrieve the device information */
947 rc = tf_session_get_device(tfs, &dev);
950 "Failed to lookup device, rc:%s\n",
955 req.ctx_id = tfp_cpu_to_le_32(*ctx_id);
957 parms.tf_type = HWRM_TF_CTXT_MEM_UNRGTR;
958 parms.req_data = (uint32_t *)&req;
959 parms.req_size = sizeof(req);
960 parms.resp_data = (uint32_t *)&resp;
961 parms.resp_size = sizeof(resp);
962 parms.mailbox = dev->ops->tf_dev_get_mailbox();
964 rc = tfp_send_msg_direct(tfp,
970 tf_msg_em_qcaps(struct tf *tfp,
972 struct tf_em_caps *em_caps)
975 struct hwrm_tf_ext_em_qcaps_input req = {0};
976 struct hwrm_tf_ext_em_qcaps_output resp = { 0 };
978 struct tfp_send_msg_parms parms = { 0 };
979 struct tf_dev_info *dev;
980 struct tf_session *tfs;
982 /* Retrieve the session information */
983 rc = tf_session_get_session_internal(tfp, &tfs);
986 "%s: Failed to lookup session, rc:%s\n",
992 /* Retrieve the device information */
993 rc = tf_session_get_device(tfs, &dev);
996 "%s: Failed to lookup device, rc:%s\n",
1002 flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_TX :
1003 HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_DIR_RX);
1004 req.flags = tfp_cpu_to_le_32(flags);
1006 parms.tf_type = HWRM_TF_EXT_EM_QCAPS;
1007 parms.req_data = (uint32_t *)&req;
1008 parms.req_size = sizeof(req);
1009 parms.resp_data = (uint32_t *)&resp;
1010 parms.resp_size = sizeof(resp);
1011 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1013 rc = tfp_send_msg_direct(tfp,
1018 em_caps->supported = tfp_le_to_cpu_32(resp.supported);
1019 em_caps->max_entries_supported =
1020 tfp_le_to_cpu_32(resp.max_entries_supported);
1021 em_caps->key_entry_size = tfp_le_to_cpu_16(resp.key_entry_size);
1022 em_caps->record_entry_size =
1023 tfp_le_to_cpu_16(resp.record_entry_size);
1024 em_caps->efc_entry_size = tfp_le_to_cpu_16(resp.efc_entry_size);
1030 tf_msg_em_cfg(struct tf *tfp,
1031 uint32_t num_entries,
1032 uint16_t key0_ctx_id,
1033 uint16_t key1_ctx_id,
1034 uint16_t record_ctx_id,
1035 uint16_t efc_ctx_id,
1036 uint8_t flush_interval,
1040 struct hwrm_tf_ext_em_cfg_input req = {0};
1041 struct hwrm_tf_ext_em_cfg_output resp = {0};
1043 struct tfp_send_msg_parms parms = { 0 };
1044 struct tf_dev_info *dev;
1045 struct tf_session *tfs;
1047 /* Retrieve the session information */
1048 rc = tf_session_get_session_internal(tfp, &tfs);
1051 "%s: Failed to lookup session, rc:%s\n",
1057 /* Retrieve the device information */
1058 rc = tf_session_get_device(tfs, &dev);
1061 "%s: Failed to lookup device, rc:%s\n",
1067 flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX :
1068 HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX);
1069 flags |= HWRM_TF_EXT_EM_QCAPS_INPUT_FLAGS_PREFERRED_OFFLOAD;
1071 req.flags = tfp_cpu_to_le_32(flags);
1072 req.num_entries = tfp_cpu_to_le_32(num_entries);
1074 req.flush_interval = flush_interval;
1076 req.key0_ctx_id = tfp_cpu_to_le_16(key0_ctx_id);
1077 req.key1_ctx_id = tfp_cpu_to_le_16(key1_ctx_id);
1078 req.record_ctx_id = tfp_cpu_to_le_16(record_ctx_id);
1079 req.efc_ctx_id = tfp_cpu_to_le_16(efc_ctx_id);
1081 parms.tf_type = HWRM_TF_EXT_EM_CFG;
1082 parms.req_data = (uint32_t *)&req;
1083 parms.req_size = sizeof(req);
1084 parms.resp_data = (uint32_t *)&resp;
1085 parms.resp_size = sizeof(resp);
1086 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1088 rc = tfp_send_msg_direct(tfp,
1094 tf_msg_em_op(struct tf *tfp,
1099 struct hwrm_tf_ext_em_op_input req = {0};
1100 struct hwrm_tf_ext_em_op_output resp = {0};
1102 struct tfp_send_msg_parms parms = { 0 };
1103 struct tf_dev_info *dev;
1104 struct tf_session *tfs;
1106 /* Retrieve the session information */
1107 rc = tf_session_get_session_internal(tfp, &tfs);
1110 "%s: Failed to lookup session, rc:%s\n",
1116 /* Retrieve the device information */
1117 rc = tf_session_get_device(tfs, &dev);
1120 "%s: Failed to lookup device, rc:%s\n",
1126 flags = (dir == TF_DIR_TX ? HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_TX :
1127 HWRM_TF_EXT_EM_CFG_INPUT_FLAGS_DIR_RX);
1128 req.flags = tfp_cpu_to_le_32(flags);
1129 req.op = tfp_cpu_to_le_16(op);
1131 parms.tf_type = HWRM_TF_EXT_EM_OP;
1132 parms.req_data = (uint32_t *)&req;
1133 parms.req_size = sizeof(req);
1134 parms.resp_data = (uint32_t *)&resp;
1135 parms.resp_size = sizeof(resp);
1136 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1138 rc = tfp_send_msg_direct(tfp,
1144 tf_msg_tcam_entry_set(struct tf *tfp,
1145 struct tf_dev_info *dev,
1146 struct tf_tcam_set_parms *parms)
1149 struct tfp_send_msg_parms mparms = { 0 };
1150 struct hwrm_tf_tcam_set_input req = { 0 };
1151 struct hwrm_tf_tcam_set_output resp = { 0 };
1152 struct tf_msg_dma_buf buf = { 0 };
1153 uint8_t *data = NULL;
1155 uint8_t fw_session_id;
1157 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1160 "%s: Unable to lookup FW id, rc:%s\n",
1161 tf_dir_2_str(parms->dir),
1166 /* Populate the request */
1167 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1168 req.type = parms->hcapi_type;
1169 req.idx = tfp_cpu_to_le_16(parms->idx);
1170 if (parms->dir == TF_DIR_TX)
1171 req.flags |= HWRM_TF_TCAM_SET_INPUT_FLAGS_DIR_TX;
1173 req.key_size = parms->key_size;
1174 req.mask_offset = parms->key_size;
1175 /* Result follows after key and mask, thus multiply by 2 */
1176 req.result_offset = 2 * parms->key_size;
1177 req.result_size = parms->result_size;
1178 data_size = 2 * req.key_size + req.result_size;
1180 if (data_size <= TF_PCI_BUF_SIZE_MAX) {
1181 /* use pci buffer */
1182 data = &req.dev_data[0];
1184 /* use dma buffer */
1185 req.flags |= HWRM_TF_TCAM_SET_INPUT_FLAGS_DMA;
1186 rc = tf_msg_alloc_dma_buf(&buf, data_size);
1190 tfp_memcpy(&req.dev_data[0],
1192 sizeof(buf.pa_addr));
1195 tfp_memcpy(&data[0], parms->key, parms->key_size);
1196 tfp_memcpy(&data[parms->key_size], parms->mask, parms->key_size);
1197 tfp_memcpy(&data[req.result_offset], parms->result, parms->result_size);
1199 mparms.tf_type = HWRM_TF_TCAM_SET;
1200 mparms.req_data = (uint32_t *)&req;
1201 mparms.req_size = sizeof(req);
1202 mparms.resp_data = (uint32_t *)&resp;
1203 mparms.resp_size = sizeof(resp);
1204 mparms.mailbox = dev->ops->tf_dev_get_mailbox();
1206 rc = tfp_send_msg_direct(tfp,
1210 tf_msg_free_dma_buf(&buf);
1216 tf_msg_tcam_entry_free(struct tf *tfp,
1217 struct tf_dev_info *dev,
1218 struct tf_tcam_free_parms *in_parms)
1221 struct hwrm_tf_tcam_free_input req = { 0 };
1222 struct hwrm_tf_tcam_free_output resp = { 0 };
1223 struct tfp_send_msg_parms parms = { 0 };
1224 uint8_t fw_session_id;
1226 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1229 "%s: Unable to lookup FW id, rc:%s\n",
1230 tf_dir_2_str(in_parms->dir),
1235 /* Populate the request */
1236 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1237 req.type = in_parms->hcapi_type;
1239 req.idx_list[0] = tfp_cpu_to_le_16(in_parms->idx);
1240 if (in_parms->dir == TF_DIR_TX)
1241 req.flags |= HWRM_TF_TCAM_FREE_INPUT_FLAGS_DIR_TX;
1243 parms.tf_type = HWRM_TF_TCAM_FREE;
1244 parms.req_data = (uint32_t *)&req;
1245 parms.req_size = sizeof(req);
1246 parms.resp_data = (uint32_t *)&resp;
1247 parms.resp_size = sizeof(resp);
1248 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1250 rc = tfp_send_msg_direct(tfp,
1256 tf_msg_set_tbl_entry(struct tf *tfp,
1258 uint16_t hcapi_type,
1264 struct hwrm_tf_tbl_type_set_input req = { 0 };
1265 struct hwrm_tf_tbl_type_set_output resp = { 0 };
1266 struct tfp_send_msg_parms parms = { 0 };
1267 uint8_t fw_session_id;
1268 struct tf_dev_info *dev;
1269 struct tf_session *tfs;
1271 /* Retrieve the session information */
1272 rc = tf_session_get_session_internal(tfp, &tfs);
1275 "%s: Failed to lookup session, rc:%s\n",
1281 /* Retrieve the device information */
1282 rc = tf_session_get_device(tfs, &dev);
1285 "%s: Failed to lookup device, rc:%s\n",
1291 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1294 "%s: Unable to lookup FW id, rc:%s\n",
1300 /* Populate the request */
1301 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1302 req.flags = tfp_cpu_to_le_16(dir);
1303 req.type = tfp_cpu_to_le_32(hcapi_type);
1304 req.size = tfp_cpu_to_le_16(size);
1305 req.index = tfp_cpu_to_le_32(index);
1307 /* Check for data size conformity */
1308 if (size > TF_MSG_TBL_TYPE_SET_DATA_SIZE) {
1311 "%s: Invalid parameters for msg type, rc:%s\n",
1317 tfp_memcpy(&req.data,
1321 parms.tf_type = HWRM_TF_TBL_TYPE_SET;
1322 parms.req_data = (uint32_t *)&req;
1323 parms.req_size = sizeof(req);
1324 parms.resp_data = (uint32_t *)&resp;
1325 parms.resp_size = sizeof(resp);
1326 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1328 rc = tfp_send_msg_direct(tfp,
1333 return tfp_le_to_cpu_32(parms.tf_resp_code);
1337 tf_msg_get_tbl_entry(struct tf *tfp,
1339 uint16_t hcapi_type,
1345 struct hwrm_tf_tbl_type_get_input req = { 0 };
1346 struct hwrm_tf_tbl_type_get_output resp = { 0 };
1347 struct tfp_send_msg_parms parms = { 0 };
1348 uint8_t fw_session_id;
1349 struct tf_dev_info *dev;
1350 struct tf_session *tfs;
1352 /* Retrieve the session information */
1353 rc = tf_session_get_session_internal(tfp, &tfs);
1356 "%s: Failed to lookup session, rc:%s\n",
1362 /* Retrieve the device information */
1363 rc = tf_session_get_device(tfs, &dev);
1366 "%s: Failed to lookup device, rc:%s\n",
1372 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1375 "%s: Unable to lookup FW id, rc:%s\n",
1381 /* Populate the request */
1382 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1383 req.flags = tfp_cpu_to_le_16(dir);
1384 req.type = tfp_cpu_to_le_32(hcapi_type);
1385 req.index = tfp_cpu_to_le_32(index);
1387 parms.tf_type = HWRM_TF_TBL_TYPE_GET;
1388 parms.req_data = (uint32_t *)&req;
1389 parms.req_size = sizeof(req);
1390 parms.resp_data = (uint32_t *)&resp;
1391 parms.resp_size = sizeof(resp);
1392 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1394 rc = tfp_send_msg_direct(tfp,
1399 /* Verify that we got enough buffer to return the requested data */
1400 if (tfp_le_to_cpu_32(resp.size) != size)
1407 return tfp_le_to_cpu_32(parms.tf_resp_code);
1410 /* HWRM Tunneled messages */
1413 tf_msg_get_global_cfg(struct tf *tfp,
1414 struct tf_global_cfg_parms *params)
1417 struct tfp_send_msg_parms parms = { 0 };
1418 struct hwrm_tf_global_cfg_get_input req = { 0 };
1419 struct hwrm_tf_global_cfg_get_output resp = { 0 };
1421 uint8_t fw_session_id;
1422 uint16_t resp_size = 0;
1423 struct tf_dev_info *dev;
1424 struct tf_session *tfs;
1426 /* Retrieve the session information */
1427 rc = tf_session_get_session_internal(tfp, &tfs);
1430 "%s: Failed to lookup session, rc:%s\n",
1431 tf_dir_2_str(params->dir),
1436 /* Retrieve the device information */
1437 rc = tf_session_get_device(tfs, &dev);
1440 "%s: Failed to lookup device, rc:%s\n",
1441 tf_dir_2_str(params->dir),
1446 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1449 "%s: Unable to lookup FW id, rc:%s\n",
1450 tf_dir_2_str(params->dir),
1455 flags = (params->dir == TF_DIR_TX ?
1456 HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_TX :
1457 HWRM_TF_GLOBAL_CFG_GET_INPUT_FLAGS_DIR_RX);
1459 /* Populate the request */
1460 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1461 req.flags = tfp_cpu_to_le_32(flags);
1462 req.type = tfp_cpu_to_le_32(params->type);
1463 req.offset = tfp_cpu_to_le_32(params->offset);
1464 req.size = tfp_cpu_to_le_32(params->config_sz_in_bytes);
1466 parms.tf_type = HWRM_TF_GLOBAL_CFG_GET;
1467 parms.req_data = (uint32_t *)&req;
1468 parms.req_size = sizeof(req);
1469 parms.resp_data = (uint32_t *)&resp;
1470 parms.resp_size = sizeof(resp);
1471 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1473 rc = tfp_send_msg_direct(tfp, &parms);
1477 /* Verify that we got enough buffer to return the requested data */
1478 resp_size = tfp_le_to_cpu_16(resp.size);
1479 if (resp_size < params->config_sz_in_bytes)
1483 tfp_memcpy(params->config,
1489 return tfp_le_to_cpu_32(parms.tf_resp_code);
1493 tf_msg_set_global_cfg(struct tf *tfp,
1494 struct tf_global_cfg_parms *params)
1497 struct tfp_send_msg_parms parms = { 0 };
1498 struct hwrm_tf_global_cfg_set_input req = { 0 };
1499 struct hwrm_tf_global_cfg_set_output resp = { 0 };
1501 uint8_t fw_session_id;
1502 struct tf_dev_info *dev;
1503 struct tf_session *tfs;
1505 /* Retrieve the session information */
1506 rc = tf_session_get_session_internal(tfp, &tfs);
1509 "%s: Failed to lookup session, rc:%s\n",
1510 tf_dir_2_str(params->dir),
1515 /* Retrieve the device information */
1516 rc = tf_session_get_device(tfs, &dev);
1519 "%s: Failed to lookup device, rc:%s\n",
1520 tf_dir_2_str(params->dir),
1525 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1528 "%s: Unable to lookup FW id, rc:%s\n",
1529 tf_dir_2_str(params->dir),
1534 flags = (params->dir == TF_DIR_TX ?
1535 HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_TX :
1536 HWRM_TF_GLOBAL_CFG_SET_INPUT_FLAGS_DIR_RX);
1538 /* Populate the request */
1539 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1540 req.flags = tfp_cpu_to_le_32(flags);
1541 req.type = tfp_cpu_to_le_32(params->type);
1542 req.offset = tfp_cpu_to_le_32(params->offset);
1544 /* Check for data size conformity */
1545 if (params->config_sz_in_bytes > TF_MSG_SET_GLOBAL_CFG_DATA_SIZE) {
1548 "%s: Invalid parameters for msg type, rc:%s\n",
1549 tf_dir_2_str(params->dir),
1554 tfp_memcpy(req.data, params->config,
1555 params->config_sz_in_bytes);
1557 /* Only set mask if pointer is provided
1559 if (params->config_mask) {
1560 tfp_memcpy(req.mask,
1561 params->config_mask,
1562 params->config_sz_in_bytes);
1565 req.size = tfp_cpu_to_le_32(params->config_sz_in_bytes);
1567 parms.tf_type = HWRM_TF_GLOBAL_CFG_SET;
1568 parms.req_data = (uint32_t *)&req;
1569 parms.req_size = sizeof(req);
1570 parms.resp_data = (uint32_t *)&resp;
1571 parms.resp_size = sizeof(resp);
1572 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1574 rc = tfp_send_msg_direct(tfp, &parms);
1579 return tfp_le_to_cpu_32(parms.tf_resp_code);
1583 tf_msg_bulk_get_tbl_entry(struct tf *tfp,
1585 uint16_t hcapi_type,
1586 uint32_t starting_idx,
1587 uint16_t num_entries,
1588 uint16_t entry_sz_in_bytes,
1589 uint64_t physical_mem_addr)
1592 struct tfp_send_msg_parms parms = { 0 };
1593 struct tf_tbl_type_bulk_get_input req = { 0 };
1594 struct tf_tbl_type_bulk_get_output resp = { 0 };
1596 uint8_t fw_session_id;
1597 struct tf_dev_info *dev;
1598 struct tf_session *tfs;
1600 /* Retrieve the session information */
1601 rc = tf_session_get_session(tfp, &tfs);
1604 "%s: Failed to lookup session, rc:%s\n",
1610 /* Retrieve the device information */
1611 rc = tf_session_get_device(tfs, &dev);
1614 "%s: Failed to lookup device, rc:%s\n",
1620 rc = tf_session_get_fw_session_id(tfp, &fw_session_id);
1623 "%s: Unable to lookup FW id, rc:%s\n",
1629 /* Populate the request */
1630 req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
1631 req.flags = tfp_cpu_to_le_16(dir);
1632 req.type = tfp_cpu_to_le_32(hcapi_type);
1633 req.start_index = tfp_cpu_to_le_32(starting_idx);
1634 req.num_entries = tfp_cpu_to_le_32(num_entries);
1636 data_size = num_entries * entry_sz_in_bytes;
1638 req.host_addr = tfp_cpu_to_le_64(physical_mem_addr);
1641 dev->ops->tf_dev_get_mailbox(),
1643 HWRM_TFT_TBL_TYPE_BULK_GET,
1647 rc = tfp_send_msg_tunneled(tfp, &parms);
1651 /* Verify that we got enough buffer to return the requested data */
1652 if (tfp_le_to_cpu_32(resp.size) != data_size)
1655 return tfp_le_to_cpu_32(parms.tf_resp_code);
1659 tf_msg_get_if_tbl_entry(struct tf *tfp,
1660 struct tf_if_tbl_get_parms *params)
1663 struct tfp_send_msg_parms parms = { 0 };
1664 struct hwrm_tf_if_tbl_get_input req = { 0 };
1665 struct hwrm_tf_if_tbl_get_output resp = { 0 };
1667 struct tf_dev_info *dev;
1668 struct tf_session *tfs;
1670 /* Retrieve the session information */
1671 rc = tf_session_get_session(tfp, &tfs);
1674 "%s: Failed to lookup session, rc:%s\n",
1675 tf_dir_2_str(params->dir),
1680 /* Retrieve the device information */
1681 rc = tf_session_get_device(tfs, &dev);
1684 "%s: Failed to lookup device, rc:%s\n",
1685 tf_dir_2_str(params->dir),
1690 flags = (params->dir == TF_DIR_TX ?
1691 HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_TX :
1692 HWRM_TF_IF_TBL_GET_INPUT_FLAGS_DIR_RX);
1694 /* Populate the request */
1696 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
1698 req.type = params->hcapi_type;
1699 req.index = tfp_cpu_to_le_16(params->idx);
1700 req.size = tfp_cpu_to_le_16(params->data_sz_in_bytes);
1702 parms.tf_type = HWRM_TF_IF_TBL_GET;
1703 parms.req_data = (uint32_t *)&req;
1704 parms.req_size = sizeof(req);
1705 parms.resp_data = (uint32_t *)&resp;
1706 parms.resp_size = sizeof(resp);
1707 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1709 rc = tfp_send_msg_direct(tfp, &parms);
1714 if (parms.tf_resp_code != 0)
1715 return tfp_le_to_cpu_32(parms.tf_resp_code);
1717 tfp_memcpy(params->data, resp.data, req.size);
1719 return tfp_le_to_cpu_32(parms.tf_resp_code);
1723 tf_msg_set_if_tbl_entry(struct tf *tfp,
1724 struct tf_if_tbl_set_parms *params)
1727 struct tfp_send_msg_parms parms = { 0 };
1728 struct hwrm_tf_if_tbl_set_input req = { 0 };
1729 struct hwrm_tf_if_tbl_get_output resp = { 0 };
1731 struct tf_dev_info *dev;
1732 struct tf_session *tfs;
1734 /* Retrieve the session information */
1735 rc = tf_session_get_session(tfp, &tfs);
1738 "%s: Failed to lookup session, rc:%s\n",
1739 tf_dir_2_str(params->dir),
1744 /* Retrieve the device information */
1745 rc = tf_session_get_device(tfs, &dev);
1749 flags = (params->dir == TF_DIR_TX ?
1750 HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_TX :
1751 HWRM_TF_IF_TBL_SET_INPUT_FLAGS_DIR_RX);
1753 /* Populate the request */
1755 tfp_cpu_to_le_32(tfs->session_id.internal.fw_session_id);
1757 req.type = params->hcapi_type;
1758 req.index = tfp_cpu_to_le_32(params->idx);
1759 req.size = tfp_cpu_to_le_32(params->data_sz_in_bytes);
1760 tfp_memcpy(&req.data[0], params->data, params->data_sz_in_bytes);
1762 parms.tf_type = HWRM_TF_IF_TBL_SET;
1763 parms.req_data = (uint32_t *)&req;
1764 parms.req_size = sizeof(req);
1765 parms.resp_data = (uint32_t *)&resp;
1766 parms.resp_size = sizeof(resp);
1767 parms.mailbox = dev->ops->tf_dev_get_mailbox();
1769 rc = tfp_send_msg_direct(tfp, &parms);
1774 return tfp_le_to_cpu_32(parms.tf_resp_code);