1131a75b6SHemant Agrawal /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) 208464d29SNipun Gupta * 308464d29SNipun Gupta * Copyright 2013-2016 Freescale Semiconductor Inc. 4f513f620SSachin Saxena * Copyright 2017-2019 NXP 508464d29SNipun Gupta * 608464d29SNipun Gupta */ 708464d29SNipun Gupta #ifndef __FSL_DPCI_H 808464d29SNipun Gupta #define __FSL_DPCI_H 908464d29SNipun Gupta 10b4a63e60SHemant Agrawal #include <fsl_dpopr.h> 11b4a63e60SHemant Agrawal 12*1094dd94SDavid Marchand #include <rte_compat.h> 13*1094dd94SDavid Marchand 1408464d29SNipun Gupta /* Data Path Communication Interface API 1508464d29SNipun Gupta * Contains initialization APIs and runtime control APIs for DPCI 1608464d29SNipun Gupta */ 1708464d29SNipun Gupta 1808464d29SNipun Gupta struct fsl_mc_io; 1908464d29SNipun Gupta 2008464d29SNipun Gupta /** General DPCI macros */ 2108464d29SNipun Gupta 2208464d29SNipun Gupta /** 2308464d29SNipun Gupta * Maximum number of Tx/Rx priorities per DPCI object 2408464d29SNipun Gupta */ 25b4a63e60SHemant Agrawal #define DPCI_PRIO_NUM 4 2608464d29SNipun Gupta 2708464d29SNipun Gupta /** 2808464d29SNipun Gupta * Indicates an invalid frame queue 2908464d29SNipun Gupta */ 3008464d29SNipun Gupta #define DPCI_FQID_NOT_VALID (uint32_t)(-1) 3108464d29SNipun Gupta 3208464d29SNipun Gupta /** 3308464d29SNipun Gupta * All queues considered; see dpci_set_rx_queue() 3408464d29SNipun Gupta */ 3508464d29SNipun Gupta #define DPCI_ALL_QUEUES (uint8_t)(-1) 3608464d29SNipun Gupta 3708464d29SNipun Gupta int dpci_open(struct fsl_mc_io *mc_io, 3808464d29SNipun Gupta uint32_t cmd_flags, 3908464d29SNipun Gupta int dpci_id, 4008464d29SNipun Gupta uint16_t *token); 4108464d29SNipun Gupta 4208464d29SNipun Gupta int dpci_close(struct fsl_mc_io *mc_io, 4308464d29SNipun Gupta uint32_t cmd_flags, 4408464d29SNipun Gupta uint16_t token); 4508464d29SNipun Gupta 4608464d29SNipun Gupta /** 4708464d29SNipun Gupta * Enable the Order Restoration support 4808464d29SNipun Gupta */ 4908464d29SNipun Gupta #define DPCI_OPT_HAS_OPR 0x000040 5008464d29SNipun Gupta 5108464d29SNipun Gupta /** 5208464d29SNipun Gupta * Order Point Records are shared for the entire DPCI 5308464d29SNipun Gupta */ 5408464d29SNipun Gupta #define DPCI_OPT_OPR_SHARED 0x000080 5508464d29SNipun Gupta 5608464d29SNipun Gupta /** 5708464d29SNipun Gupta * struct dpci_cfg - Structure representing DPCI configuration 5808464d29SNipun Gupta * @options: Any combination of the following options: 5908464d29SNipun Gupta * DPCI_OPT_HAS_OPR 6008464d29SNipun Gupta * DPCI_OPT_OPR_SHARED 6108464d29SNipun Gupta * @num_of_priorities: Number of receive priorities (queues) for the DPCI; 6208464d29SNipun Gupta * note, that the number of transmit priorities (queues) 6308464d29SNipun Gupta * is determined by the number of receive priorities of 6408464d29SNipun Gupta * the peer DPCI object 6508464d29SNipun Gupta */ 6608464d29SNipun Gupta struct dpci_cfg { 6708464d29SNipun Gupta uint32_t options; 6808464d29SNipun Gupta uint8_t num_of_priorities; 6908464d29SNipun Gupta }; 7008464d29SNipun Gupta 7108464d29SNipun Gupta int dpci_create(struct fsl_mc_io *mc_io, 7208464d29SNipun Gupta uint16_t dprc_token, 7308464d29SNipun Gupta uint32_t cmd_flags, 7408464d29SNipun Gupta const struct dpci_cfg *cfg, 7508464d29SNipun Gupta uint32_t *obj_id); 7608464d29SNipun Gupta 7708464d29SNipun Gupta int dpci_destroy(struct fsl_mc_io *mc_io, 7808464d29SNipun Gupta uint16_t dprc_token, 7908464d29SNipun Gupta uint32_t cmd_flags, 8008464d29SNipun Gupta uint32_t object_id); 8108464d29SNipun Gupta 8208464d29SNipun Gupta int dpci_enable(struct fsl_mc_io *mc_io, 8308464d29SNipun Gupta uint32_t cmd_flags, 8408464d29SNipun Gupta uint16_t token); 8508464d29SNipun Gupta 8608464d29SNipun Gupta int dpci_disable(struct fsl_mc_io *mc_io, 8708464d29SNipun Gupta uint32_t cmd_flags, 8808464d29SNipun Gupta uint16_t token); 8908464d29SNipun Gupta 9008464d29SNipun Gupta int dpci_is_enabled(struct fsl_mc_io *mc_io, 9108464d29SNipun Gupta uint32_t cmd_flags, 9208464d29SNipun Gupta uint16_t token, 9308464d29SNipun Gupta int *en); 9408464d29SNipun Gupta 9508464d29SNipun Gupta int dpci_reset(struct fsl_mc_io *mc_io, 9608464d29SNipun Gupta uint32_t cmd_flags, 9708464d29SNipun Gupta uint16_t token); 9808464d29SNipun Gupta 9908464d29SNipun Gupta /** 10008464d29SNipun Gupta * struct dpci_attr - Structure representing DPCI attributes 10108464d29SNipun Gupta * @id: DPCI object ID 10208464d29SNipun Gupta * @num_of_priorities: Number of receive priorities 10308464d29SNipun Gupta */ 10408464d29SNipun Gupta struct dpci_attr { 10508464d29SNipun Gupta int id; 10608464d29SNipun Gupta uint8_t num_of_priorities; 10708464d29SNipun Gupta }; 10808464d29SNipun Gupta 10908464d29SNipun Gupta int dpci_get_attributes(struct fsl_mc_io *mc_io, 11008464d29SNipun Gupta uint32_t cmd_flags, 11108464d29SNipun Gupta uint16_t token, 11208464d29SNipun Gupta struct dpci_attr *attr); 11308464d29SNipun Gupta 11408464d29SNipun Gupta /** 11508464d29SNipun Gupta * enum dpci_dest - DPCI destination types 11608464d29SNipun Gupta * @DPCI_DEST_NONE: Unassigned destination; The queue is set in parked mode 11708464d29SNipun Gupta * and does not generate FQDAN notifications; user is 11808464d29SNipun Gupta * expected to dequeue from the queue based on polling or 11908464d29SNipun Gupta * other user-defined method 12008464d29SNipun Gupta * @DPCI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN 12108464d29SNipun Gupta * notifications to the specified DPIO; user is expected 12208464d29SNipun Gupta * to dequeue from the queue only after notification is 12308464d29SNipun Gupta * received 12408464d29SNipun Gupta * @DPCI_DEST_DPCON: The queue is set in schedule mode and does not generate 12508464d29SNipun Gupta * FQDAN notifications, but is connected to the specified 12608464d29SNipun Gupta * DPCON object; 12708464d29SNipun Gupta * user is expected to dequeue from the DPCON channel 12808464d29SNipun Gupta */ 12908464d29SNipun Gupta enum dpci_dest { 13008464d29SNipun Gupta DPCI_DEST_NONE = 0, 13108464d29SNipun Gupta DPCI_DEST_DPIO = 1, 13208464d29SNipun Gupta DPCI_DEST_DPCON = 2 13308464d29SNipun Gupta }; 13408464d29SNipun Gupta 13508464d29SNipun Gupta /** 13608464d29SNipun Gupta * struct dpci_dest_cfg - Structure representing DPCI destination configuration 13708464d29SNipun Gupta * @dest_type: Destination type 13808464d29SNipun Gupta * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type 13908464d29SNipun Gupta * @priority: Priority selection within the DPIO or DPCON channel; valid 14008464d29SNipun Gupta * values are 0-1 or 0-7, depending on the number of priorities 14108464d29SNipun Gupta * in that channel; not relevant for 'DPCI_DEST_NONE' option 14208464d29SNipun Gupta */ 14308464d29SNipun Gupta struct dpci_dest_cfg { 14408464d29SNipun Gupta enum dpci_dest dest_type; 14508464d29SNipun Gupta int dest_id; 14608464d29SNipun Gupta uint8_t priority; 14708464d29SNipun Gupta }; 14808464d29SNipun Gupta 14908464d29SNipun Gupta /** DPCI queue modification options */ 15008464d29SNipun Gupta 15108464d29SNipun Gupta /** 15208464d29SNipun Gupta * Select to modify the user's context associated with the queue 15308464d29SNipun Gupta */ 15408464d29SNipun Gupta #define DPCI_QUEUE_OPT_USER_CTX 0x00000001 15508464d29SNipun Gupta 15608464d29SNipun Gupta /** 15708464d29SNipun Gupta * Select to modify the queue's destination 15808464d29SNipun Gupta */ 15908464d29SNipun Gupta #define DPCI_QUEUE_OPT_DEST 0x00000002 16008464d29SNipun Gupta 16108464d29SNipun Gupta /** 162b4a63e60SHemant Agrawal * Set the queue to hold active mode. 163b4a63e60SHemant Agrawal */ 164b4a63e60SHemant Agrawal #define DPCI_QUEUE_OPT_HOLD_ACTIVE 0x00000004 165b4a63e60SHemant Agrawal 166b4a63e60SHemant Agrawal /** 16708464d29SNipun Gupta * struct dpci_rx_queue_cfg - Structure representing RX queue configuration 16808464d29SNipun Gupta * @options: Flags representing the suggested modifications to the queue; 16908464d29SNipun Gupta * Use any combination of 'DPCI_QUEUE_OPT_<X>' flags 17008464d29SNipun Gupta * @user_ctx: User context value provided in the frame descriptor of each 17108464d29SNipun Gupta * dequeued frame; 17208464d29SNipun Gupta * valid only if 'DPCI_QUEUE_OPT_USER_CTX' is contained in 17308464d29SNipun Gupta * 'options' 17408464d29SNipun Gupta * @dest_cfg: Queue destination parameters; 17508464d29SNipun Gupta * valid only if 'DPCI_QUEUE_OPT_DEST' is contained in 'options' 176b4a63e60SHemant Agrawal * @order_preservation_en: order preservation configuration for the rx queue 177b4a63e60SHemant Agrawal * valid only if 'DPCI_QUEUE_OPT_HOLD_ACTIVE' is contained in 'options' 17808464d29SNipun Gupta */ 17908464d29SNipun Gupta struct dpci_rx_queue_cfg { 18008464d29SNipun Gupta uint32_t options; 18108464d29SNipun Gupta uint64_t user_ctx; 18208464d29SNipun Gupta struct dpci_dest_cfg dest_cfg; 183b4a63e60SHemant Agrawal int order_preservation_en; 18408464d29SNipun Gupta }; 18508464d29SNipun Gupta 186c9da6cfaSHemant Agrawal __rte_internal 18708464d29SNipun Gupta int dpci_set_rx_queue(struct fsl_mc_io *mc_io, 18808464d29SNipun Gupta uint32_t cmd_flags, 18908464d29SNipun Gupta uint16_t token, 19008464d29SNipun Gupta uint8_t priority, 19108464d29SNipun Gupta const struct dpci_rx_queue_cfg *cfg); 19208464d29SNipun Gupta 19308464d29SNipun Gupta /** 19408464d29SNipun Gupta * struct dpci_rx_queue_attr - Structure representing Rx queue attributes 19508464d29SNipun Gupta * @user_ctx: User context value provided in the frame descriptor of each 19608464d29SNipun Gupta * dequeued frame 19708464d29SNipun Gupta * @dest_cfg: Queue destination configuration 19808464d29SNipun Gupta * @fqid: Virtual FQID value to be used for dequeue operations 19908464d29SNipun Gupta */ 20008464d29SNipun Gupta struct dpci_rx_queue_attr { 20108464d29SNipun Gupta uint64_t user_ctx; 20208464d29SNipun Gupta struct dpci_dest_cfg dest_cfg; 20308464d29SNipun Gupta uint32_t fqid; 20408464d29SNipun Gupta }; 20508464d29SNipun Gupta 20608464d29SNipun Gupta int dpci_get_rx_queue(struct fsl_mc_io *mc_io, 20708464d29SNipun Gupta uint32_t cmd_flags, 20808464d29SNipun Gupta uint16_t token, 20908464d29SNipun Gupta uint8_t priority, 21008464d29SNipun Gupta struct dpci_rx_queue_attr *attr); 21108464d29SNipun Gupta 21208464d29SNipun Gupta /** 21308464d29SNipun Gupta * struct dpci_tx_queue_attr - Structure representing attributes of Tx queues 21408464d29SNipun Gupta * @fqid: Virtual FQID to be used for sending frames to peer DPCI; 21508464d29SNipun Gupta * returns 'DPCI_FQID_NOT_VALID' if a no peer is connected or if 21608464d29SNipun Gupta * the selected priority exceeds the number of priorities of the 21708464d29SNipun Gupta * peer DPCI object 21808464d29SNipun Gupta */ 21908464d29SNipun Gupta struct dpci_tx_queue_attr { 22008464d29SNipun Gupta uint32_t fqid; 22108464d29SNipun Gupta }; 22208464d29SNipun Gupta 22308464d29SNipun Gupta int dpci_get_tx_queue(struct fsl_mc_io *mc_io, 22408464d29SNipun Gupta uint32_t cmd_flags, 22508464d29SNipun Gupta uint16_t token, 22608464d29SNipun Gupta uint8_t priority, 22708464d29SNipun Gupta struct dpci_tx_queue_attr *attr); 22808464d29SNipun Gupta 22908464d29SNipun Gupta int dpci_get_api_version(struct fsl_mc_io *mc_io, 23008464d29SNipun Gupta uint32_t cmd_flags, 23108464d29SNipun Gupta uint16_t *major_ver, 23208464d29SNipun Gupta uint16_t *minor_ver); 23308464d29SNipun Gupta 234c9da6cfaSHemant Agrawal __rte_internal 235b4a63e60SHemant Agrawal int dpci_set_opr(struct fsl_mc_io *mc_io, 236b4a63e60SHemant Agrawal uint32_t cmd_flags, 237b4a63e60SHemant Agrawal uint16_t token, 238b4a63e60SHemant Agrawal uint8_t index, 239b4a63e60SHemant Agrawal uint8_t options, 240b4a63e60SHemant Agrawal struct opr_cfg *cfg); 241b4a63e60SHemant Agrawal 242c9da6cfaSHemant Agrawal __rte_internal 243b4a63e60SHemant Agrawal int dpci_get_opr(struct fsl_mc_io *mc_io, 244b4a63e60SHemant Agrawal uint32_t cmd_flags, 245b4a63e60SHemant Agrawal uint16_t token, 246b4a63e60SHemant Agrawal uint8_t index, 247b4a63e60SHemant Agrawal struct opr_cfg *cfg, 248b4a63e60SHemant Agrawal struct opr_qry *qry); 249b4a63e60SHemant Agrawal 25008464d29SNipun Gupta #endif /* __FSL_DPCI_H */ 251