1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2023 Advanced Micro Devices, Inc */
4 #ifndef _PDS_CORE_ADMINQ_H_
5 #define _PDS_CORE_ADMINQ_H_
7 #define PDSC_ADMINQ_MAX_POLL_INTERVAL 256
9 enum pds_core_adminq_flags
{
10 PDS_AQ_FLAG_FASTPOLL
= BIT(1), /* completion poll at 1ms */
14 * enum pds_core_adminq_opcode - AdminQ command opcodes
15 * These commands are only processed on AdminQ, not available in devcmd
17 enum pds_core_adminq_opcode
{
21 PDS_AQ_CMD_CLIENT_REG
= 6,
22 PDS_AQ_CMD_CLIENT_UNREG
= 7,
23 PDS_AQ_CMD_CLIENT_CMD
= 8,
26 PDS_AQ_CMD_LIF_IDENTIFY
= 20,
27 PDS_AQ_CMD_LIF_INIT
= 21,
28 PDS_AQ_CMD_LIF_RESET
= 22,
29 PDS_AQ_CMD_LIF_GETATTR
= 23,
30 PDS_AQ_CMD_LIF_SETATTR
= 24,
31 PDS_AQ_CMD_LIF_SETPHC
= 25,
33 PDS_AQ_CMD_RX_MODE_SET
= 30,
34 PDS_AQ_CMD_RX_FILTER_ADD
= 31,
35 PDS_AQ_CMD_RX_FILTER_DEL
= 32,
38 PDS_AQ_CMD_Q_IDENTIFY
= 39,
39 PDS_AQ_CMD_Q_INIT
= 40,
40 PDS_AQ_CMD_Q_CONTROL
= 41,
43 PDS_AQ_CMD_VF_GETATTR
= 60,
44 PDS_AQ_CMD_VF_SETATTR
= 61,
48 * enum pds_core_notifyq_opcode - NotifyQ event codes
50 enum pds_core_notifyq_opcode
{
51 PDS_EVENT_LINK_CHANGE
= 1,
57 #define PDS_COMP_COLOR_MASK 0x80
60 * struct pds_core_notifyq_event - Generic event reporting structure
64 * This is the generic event report struct from which the other
65 * actual events will be formed.
67 struct pds_core_notifyq_event
{
73 * struct pds_core_link_change_event - Link change event notification
75 * @ecode: event code = PDS_EVENT_LINK_CHANGE
76 * @link_status: link up/down, with error bits
77 * @link_speed: speed of the network link
79 * Sent when the network link state changes between UP and DOWN
81 struct pds_core_link_change_event
{
85 __le32 link_speed
; /* units of 1Mbps: e.g. 10000 = 10Gbps */
89 * struct pds_core_reset_event - Reset event notification
91 * @ecode: event code = PDS_EVENT_RESET
92 * @reset_code: reset type
93 * @state: 0=pending, 1=complete, 2=error
95 * Sent when the NIC or some subsystem is going to be or
98 struct pds_core_reset_event
{
106 * struct pds_core_client_event - Client event notification
108 * @ecode: event code = PDS_EVENT_CLIENT
109 * @client_id: client to sent event to
110 * @client_event: wrapped event struct for the client
112 * Sent when an event needs to be passed on to a client
114 struct pds_core_client_event
{
122 * struct pds_core_notifyq_cmd - Placeholder for building qcq
123 * @data: anonymous field for building the qcq
125 struct pds_core_notifyq_cmd
{
126 __le32 data
; /* Not used but needed for qcq structure */
130 * union pds_core_notifyq_comp - Overlay of notifyq event structures
132 union pds_core_notifyq_comp
{
137 struct pds_core_notifyq_event event
;
138 struct pds_core_link_change_event link_change
;
139 struct pds_core_reset_event reset
;
143 #define PDS_DEVNAME_LEN 32
145 * struct pds_core_client_reg_cmd - Register a new client with DSC
146 * @opcode: opcode PDS_AQ_CMD_CLIENT_REG
147 * @rsvd: word boundary padding
148 * @devname: text name of client device
149 * @vif_type: what type of device (enum pds_core_vif_types)
151 * Tell the DSC of the new client, and receive a client_id from DSC.
153 struct pds_core_client_reg_cmd
{
156 char devname
[PDS_DEVNAME_LEN
];
161 * struct pds_core_client_reg_comp - Client registration completion
162 * @status: Status of the command (enum pdc_core_status_code)
163 * @rsvd: Word boundary padding
164 * @comp_index: Index in the descriptor ring for which this is the completion
165 * @client_id: New id assigned by DSC
166 * @rsvd1: Word boundary padding
169 struct pds_core_client_reg_comp
{
179 * struct pds_core_client_unreg_cmd - Unregister a client from DSC
180 * @opcode: opcode PDS_AQ_CMD_CLIENT_UNREG
181 * @rsvd: word boundary padding
182 * @client_id: id of client being removed
184 * Tell the DSC this client is going away and remove its context
185 * This uses the generic completion.
187 struct pds_core_client_unreg_cmd
{
194 * struct pds_core_client_request_cmd - Pass along a wrapped client AdminQ cmd
195 * @opcode: opcode PDS_AQ_CMD_CLIENT_CMD
196 * @rsvd: word boundary padding
197 * @client_id: id of client being removed
198 * @client_cmd: the wrapped client command
200 * Proxy post an adminq command for the client.
201 * This uses the generic completion.
203 struct pds_core_client_request_cmd
{
210 #define PDS_CORE_MAX_FRAGS 16
212 #define PDS_CORE_QCQ_F_INITED BIT(0)
213 #define PDS_CORE_QCQ_F_SG BIT(1)
214 #define PDS_CORE_QCQ_F_INTR BIT(2)
215 #define PDS_CORE_QCQ_F_TX_STATS BIT(3)
216 #define PDS_CORE_QCQ_F_RX_STATS BIT(4)
217 #define PDS_CORE_QCQ_F_NOTIFYQ BIT(5)
218 #define PDS_CORE_QCQ_F_CMB_RINGS BIT(6)
219 #define PDS_CORE_QCQ_F_CORE BIT(7)
221 enum pds_core_lif_type
{
222 PDS_CORE_LIF_TYPE_DEFAULT
= 0,
225 #define PDS_CORE_IFNAMSIZ 16
228 * enum pds_core_logical_qtype - Logical Queue Types
229 * @PDS_CORE_QTYPE_ADMINQ: Administrative Queue
230 * @PDS_CORE_QTYPE_NOTIFYQ: Notify Queue
231 * @PDS_CORE_QTYPE_RXQ: Receive Queue
232 * @PDS_CORE_QTYPE_TXQ: Transmit Queue
233 * @PDS_CORE_QTYPE_EQ: Event Queue
234 * @PDS_CORE_QTYPE_MAX: Max queue type supported
236 enum pds_core_logical_qtype
{
237 PDS_CORE_QTYPE_ADMINQ
= 0,
238 PDS_CORE_QTYPE_NOTIFYQ
= 1,
239 PDS_CORE_QTYPE_RXQ
= 2,
240 PDS_CORE_QTYPE_TXQ
= 3,
241 PDS_CORE_QTYPE_EQ
= 4,
243 PDS_CORE_QTYPE_MAX
= 16 /* don't change - used in struct size */
247 * union pds_core_lif_config - LIF configuration
248 * @state: LIF state (enum pds_core_lif_state)
249 * @rsvd: Word boundary padding
251 * @rsvd2: Word boundary padding
252 * @features: LIF features active (enum pds_core_hw_features)
253 * @queue_count: Queue counts per queue-type
254 * @words: Full union buffer size
256 union pds_core_lif_config
{
260 char name
[PDS_CORE_IFNAMSIZ
];
263 __le32 queue_count
[PDS_CORE_QTYPE_MAX
];
269 * struct pds_core_lif_status - LIF status register
270 * @eid: most recent NotifyQ event id
271 * @rsvd: full struct size
273 struct pds_core_lif_status
{
279 * struct pds_core_lif_info - LIF info structure
280 * @config: LIF configuration structure
281 * @status: LIF status structure
283 struct pds_core_lif_info
{
284 union pds_core_lif_config config
;
285 struct pds_core_lif_status status
;
289 * struct pds_core_lif_identity - LIF identity information (type-specific)
290 * @features: LIF features (see enum pds_core_hw_features)
291 * @version: Identify structure version
292 * @hw_index: LIF hardware index
293 * @rsvd: Word boundary padding
294 * @max_nb_sessions: Maximum number of sessions supported
295 * @rsvd2: buffer padding
296 * @config: LIF config struct with features, q counts
298 struct pds_core_lif_identity
{
303 __le32 max_nb_sessions
;
305 union pds_core_lif_config config
;
309 * struct pds_core_lif_identify_cmd - Get LIF identity info command
310 * @opcode: Opcode PDS_AQ_CMD_LIF_IDENTIFY
311 * @type: LIF type (enum pds_core_lif_type)
312 * @client_id: Client identifier
313 * @ver: Version of identify returned by device
314 * @rsvd: Word boundary padding
315 * @ident_pa: DMA address to receive identity info
317 * Firmware will copy LIF identity data (struct pds_core_lif_identity)
318 * into the buffer address given.
320 struct pds_core_lif_identify_cmd
{
330 * struct pds_core_lif_identify_comp - LIF identify command completion
331 * @status: Status of the command (enum pds_core_status_code)
332 * @ver: Version of identify returned by device
333 * @bytes: Bytes copied into the buffer
334 * @rsvd: Word boundary padding
337 struct pds_core_lif_identify_comp
{
346 * struct pds_core_lif_init_cmd - LIF init command
347 * @opcode: Opcode PDS_AQ_CMD_LIF_INIT
348 * @type: LIF type (enum pds_core_lif_type)
349 * @client_id: Client identifier
350 * @rsvd: Word boundary padding
351 * @info_pa: Destination address for LIF info (struct pds_core_lif_info)
353 struct pds_core_lif_init_cmd
{
362 * struct pds_core_lif_init_comp - LIF init command completion
363 * @status: Status of the command (enum pds_core_status_code)
364 * @rsvd: Word boundary padding
365 * @hw_index: Hardware index of the initialized LIF
366 * @rsvd1: Word boundary padding
369 struct pds_core_lif_init_comp
{
378 * struct pds_core_lif_reset_cmd - LIF reset command
379 * Will reset only the specified LIF.
380 * @opcode: Opcode PDS_AQ_CMD_LIF_RESET
381 * @rsvd: Word boundary padding
382 * @client_id: Client identifier
384 struct pds_core_lif_reset_cmd
{
391 * enum pds_core_lif_attr - List of LIF attributes
392 * @PDS_CORE_LIF_ATTR_STATE: LIF state attribute
393 * @PDS_CORE_LIF_ATTR_NAME: LIF name attribute
394 * @PDS_CORE_LIF_ATTR_FEATURES: LIF features attribute
395 * @PDS_CORE_LIF_ATTR_STATS_CTRL: LIF statistics control attribute
397 enum pds_core_lif_attr
{
398 PDS_CORE_LIF_ATTR_STATE
= 0,
399 PDS_CORE_LIF_ATTR_NAME
= 1,
400 PDS_CORE_LIF_ATTR_FEATURES
= 4,
401 PDS_CORE_LIF_ATTR_STATS_CTRL
= 6,
405 * struct pds_core_lif_setattr_cmd - Set LIF attributes on the NIC
406 * @opcode: Opcode PDS_AQ_CMD_LIF_SETATTR
407 * @attr: Attribute type (enum pds_core_lif_attr)
408 * @client_id: Client identifier
409 * @state: LIF state (enum pds_core_lif_state)
410 * @name: The name string, 0 terminated
411 * @features: Features (enum pds_core_hw_features)
412 * @stats_ctl: Stats control commands (enum pds_core_stats_ctl_cmd)
413 * @rsvd: Command Buffer padding
415 struct pds_core_lif_setattr_cmd
{
421 char name
[PDS_CORE_IFNAMSIZ
];
429 * struct pds_core_lif_setattr_comp - LIF set attr command completion
430 * @status: Status of the command (enum pds_core_status_code)
431 * @rsvd: Word boundary padding
432 * @comp_index: Index in the descriptor ring for which this is the completion
433 * @features: Features (enum pds_core_hw_features)
434 * @rsvd2: Word boundary padding
437 struct pds_core_lif_setattr_comp
{
449 * struct pds_core_lif_getattr_cmd - Get LIF attributes from the NIC
450 * @opcode: Opcode PDS_AQ_CMD_LIF_GETATTR
451 * @attr: Attribute type (enum pds_core_lif_attr)
452 * @client_id: Client identifier
454 struct pds_core_lif_getattr_cmd
{
461 * struct pds_core_lif_getattr_comp - LIF get attr command completion
462 * @status: Status of the command (enum pds_core_status_code)
463 * @rsvd: Word boundary padding
464 * @comp_index: Index in the descriptor ring for which this is the completion
465 * @state: LIF state (enum pds_core_lif_state)
466 * @name: LIF name string, 0 terminated
467 * @features: Features (enum pds_core_hw_features)
468 * @rsvd2: Word boundary padding
471 struct pds_core_lif_getattr_comp
{
484 * union pds_core_q_identity - Queue identity information
485 * @version: Queue type version that can be used with FW
486 * @supported: Bitfield of queue versions, first bit = ver 0
487 * @rsvd: Word boundary padding
488 * @features: Queue features
489 * @desc_sz: Descriptor size
490 * @comp_sz: Completion descriptor size
491 * @rsvd2: Word boundary padding
493 struct pds_core_q_identity
{
497 #define PDS_CORE_QIDENT_F_CQ 0x01 /* queue has completion ring */
505 * struct pds_core_q_identify_cmd - queue identify command
506 * @opcode: Opcode PDS_AQ_CMD_Q_IDENTIFY
507 * @type: Logical queue type (enum pds_core_logical_qtype)
508 * @client_id: Client identifier
509 * @ver: Highest queue type version that the driver supports
510 * @rsvd: Word boundary padding
511 * @ident_pa: DMA address to receive the data (struct pds_core_q_identity)
513 struct pds_core_q_identify_cmd
{
523 * struct pds_core_q_identify_comp - queue identify command completion
524 * @status: Status of the command (enum pds_core_status_code)
525 * @rsvd: Word boundary padding
526 * @comp_index: Index in the descriptor ring for which this is the completion
527 * @ver: Queue type version that can be used with FW
528 * @rsvd1: Word boundary padding
531 struct pds_core_q_identify_comp
{
541 * struct pds_core_q_init_cmd - Queue init command
542 * @opcode: Opcode PDS_AQ_CMD_Q_INIT
543 * @type: Logical queue type
544 * @client_id: Client identifier
545 * @ver: Queue type version
546 * @rsvd: Word boundary padding
547 * @index: (LIF, qtype) relative admin queue index
548 * @intr_index: Interrupt control register index, or Event queue index
551 * IRQ: Interrupt requested on completion
552 * ENA: Enable the queue. If ENA=0 the queue is initialized
553 * but remains disabled, to be later enabled with the
554 * Queue Enable command. If ENA=1, then queue is
555 * initialized and then enabled.
556 * @cos: Class of service for this queue
557 * @ring_size: Queue ring size, encoded as a log2(size), in
558 * number of descriptors. The actual ring size is
559 * (1 << ring_size). For example, to select a ring size
560 * of 64 descriptors write ring_size = 6. The minimum
561 * ring_size value is 2 for a ring of 4 descriptors.
562 * The maximum ring_size value is 12 for a ring of 4k
563 * descriptors. Values of ring_size <2 and >12 are
565 * @ring_base: Queue ring base address
566 * @cq_ring_base: Completion queue ring base address
568 struct pds_core_q_init_cmd
{
578 #define PDS_CORE_QINIT_F_IRQ 0x01 /* Request interrupt on completion */
579 #define PDS_CORE_QINIT_F_ENA 0x02 /* Enable the queue */
581 #define PDS_CORE_QSIZE_MIN_LG2 2
582 #define PDS_CORE_QSIZE_MAX_LG2 12
589 * struct pds_core_q_init_comp - Queue init command completion
590 * @status: Status of the command (enum pds_core_status_code)
591 * @rsvd: Word boundary padding
592 * @comp_index: Index in the descriptor ring for which this is the completion
593 * @hw_index: Hardware Queue ID
594 * @hw_type: Hardware Queue type
595 * @rsvd2: Word boundary padding
598 struct pds_core_q_init_comp
{
609 * enum pds_vdpa_cmd_opcode - vDPA Device commands
611 enum pds_vdpa_cmd_opcode
{
612 PDS_VDPA_CMD_INIT
= 48,
613 PDS_VDPA_CMD_IDENT
= 49,
614 PDS_VDPA_CMD_RESET
= 51,
615 PDS_VDPA_CMD_VQ_RESET
= 52,
616 PDS_VDPA_CMD_VQ_INIT
= 53,
617 PDS_VDPA_CMD_STATUS_UPDATE
= 54,
618 PDS_VDPA_CMD_SET_FEATURES
= 55,
619 PDS_VDPA_CMD_SET_ATTR
= 56,
623 * struct pds_vdpa_cmd - generic command
625 * @vdpa_index: Index for vdpa subdevice
628 struct pds_vdpa_cmd
{
635 * struct pds_vdpa_init_cmd - INIT command
636 * @opcode: Opcode PDS_VDPA_CMD_INIT
637 * @vdpa_index: Index for vdpa subdevice
640 struct pds_vdpa_init_cmd
{
647 * struct pds_vdpa_ident - vDPA identification data
648 * @hw_features: vDPA features supported by device
649 * @max_vqs: max queues available (2 queues for a single queuepair)
650 * @max_qlen: log(2) of maximum number of descriptors
651 * @min_qlen: log(2) of minimum number of descriptors
653 * This struct is used in a DMA block that is set up for the PDS_VDPA_CMD_IDENT
654 * transaction. Set up the DMA block and send the address in the IDENT cmd
655 * data, the DSC will write the ident information, then we can remove the DMA
656 * block after reading the answer. If the completion status is 0, then there
657 * is valid information, else there was an error and the data should be invalid.
659 struct pds_vdpa_ident
{
667 * struct pds_vdpa_ident_cmd - IDENT command
668 * @opcode: Opcode PDS_VDPA_CMD_IDENT
669 * @rsvd: Word boundary padding
671 * @len: length of ident info DMA space
672 * @ident_pa: address for DMA of ident info (struct pds_vdpa_ident)
673 * only used for this transaction, then forgotten by DSC
675 struct pds_vdpa_ident_cmd
{
684 * struct pds_vdpa_status_cmd - STATUS_UPDATE command
685 * @opcode: Opcode PDS_VDPA_CMD_STATUS_UPDATE
686 * @vdpa_index: Index for vdpa subdevice
688 * @status: new status bits
690 struct pds_vdpa_status_cmd
{
698 * enum pds_vdpa_attr - List of VDPA device attributes
699 * @PDS_VDPA_ATTR_MAC: MAC address
700 * @PDS_VDPA_ATTR_MAX_VQ_PAIRS: Max virtqueue pairs
703 PDS_VDPA_ATTR_MAC
= 1,
704 PDS_VDPA_ATTR_MAX_VQ_PAIRS
= 2,
708 * struct pds_vdpa_setattr_cmd - SET_ATTR command
709 * @opcode: Opcode PDS_VDPA_CMD_SET_ATTR
710 * @vdpa_index: Index for vdpa subdevice
712 * @attr: attribute to be changed (enum pds_vdpa_attr)
713 * @pad: Word boundary padding
714 * @mac: new mac address to be assigned as vdpa device address
715 * @max_vq_pairs: new limit of virtqueue pairs
717 struct pds_vdpa_setattr_cmd
{
730 * struct pds_vdpa_vq_init_cmd - queue init command
731 * @opcode: Opcode PDS_VDPA_CMD_VQ_INIT
732 * @vdpa_index: Index for vdpa subdevice
734 * @qid: Queue id (bit0 clear = rx, bit0 set = tx, qid=N is ctrlq)
735 * @len: log(2) of max descriptor count
736 * @desc_addr: DMA address of descriptor area
737 * @avail_addr: DMA address of available descriptors (aka driver area)
738 * @used_addr: DMA address of used descriptors (aka device area)
739 * @intr_index: interrupt index
740 * @avail_index: initial device position in available ring
741 * @used_index: initial device position in used ring
743 struct pds_vdpa_vq_init_cmd
{
758 * struct pds_vdpa_vq_init_comp - queue init completion
759 * @status: Status of the command (enum pds_core_status_code)
760 * @hw_qtype: HW queue type, used in doorbell selection
761 * @hw_qindex: HW queue index, used in doorbell selection
762 * @rsvd: Word boundary padding
765 struct pds_vdpa_vq_init_comp
{
774 * struct pds_vdpa_vq_reset_cmd - queue reset command
775 * @opcode: Opcode PDS_VDPA_CMD_VQ_RESET
776 * @vdpa_index: Index for vdpa subdevice
780 struct pds_vdpa_vq_reset_cmd
{
788 * struct pds_vdpa_vq_reset_comp - queue reset completion
789 * @status: Status of the command (enum pds_core_status_code)
790 * @rsvd0: Word boundary padding
791 * @avail_index: current device position in available ring
792 * @used_index: current device position in used ring
793 * @rsvd: Word boundary padding
796 struct pds_vdpa_vq_reset_comp
{
806 * struct pds_vdpa_set_features_cmd - set hw features
807 * @opcode: Opcode PDS_VDPA_CMD_SET_FEATURES
808 * @vdpa_index: Index for vdpa subdevice
810 * @rsvd: Word boundary padding
811 * @features: Feature bit mask
813 struct pds_vdpa_set_features_cmd
{
821 #define PDS_LM_DEVICE_STATE_LENGTH 65536
822 #define PDS_LM_CHECK_DEVICE_STATE_LENGTH(X) \
823 PDS_CORE_SIZE_CHECK(union, PDS_LM_DEVICE_STATE_LENGTH, X)
826 * enum pds_lm_cmd_opcode - Live Migration Device commands
828 enum pds_lm_cmd_opcode
{
829 PDS_LM_CMD_HOST_VF_STATUS
= 1,
831 /* Device state commands */
832 PDS_LM_CMD_STATE_SIZE
= 16,
833 PDS_LM_CMD_SUSPEND
= 18,
834 PDS_LM_CMD_SUSPEND_STATUS
= 19,
835 PDS_LM_CMD_RESUME
= 20,
836 PDS_LM_CMD_SAVE
= 21,
837 PDS_LM_CMD_RESTORE
= 22,
839 /* Dirty page tracking commands */
840 PDS_LM_CMD_DIRTY_STATUS
= 32,
841 PDS_LM_CMD_DIRTY_ENABLE
= 33,
842 PDS_LM_CMD_DIRTY_DISABLE
= 34,
843 PDS_LM_CMD_DIRTY_READ_SEQ
= 35,
844 PDS_LM_CMD_DIRTY_WRITE_ACK
= 36,
848 * struct pds_lm_cmd - generic command
850 * @rsvd: Word boundary padding
852 * @rsvd2: Structure padding to 60 Bytes
862 * struct pds_lm_state_size_cmd - STATE_SIZE command
864 * @rsvd: Word boundary padding
867 struct pds_lm_state_size_cmd
{
874 * struct pds_lm_state_size_comp - STATE_SIZE command completion
875 * @status: Status of the command (enum pds_core_status_code)
876 * @rsvd: Word boundary padding
877 * @comp_index: Index in the desc ring for which this is the completion
878 * @size: Size of the device state
879 * @rsvd2: Word boundary padding
882 struct pds_lm_state_size_comp
{
893 enum pds_lm_suspend_resume_type
{
894 PDS_LM_SUSPEND_RESUME_TYPE_FULL
= 0,
895 PDS_LM_SUSPEND_RESUME_TYPE_P2P
= 1,
899 * struct pds_lm_suspend_cmd - SUSPEND command
900 * @opcode: Opcode PDS_LM_CMD_SUSPEND
901 * @rsvd: Word boundary padding
903 * @type: Type of suspend (enum pds_lm_suspend_resume_type)
905 struct pds_lm_suspend_cmd
{
913 * struct pds_lm_suspend_status_cmd - SUSPEND status command
914 * @opcode: Opcode PDS_AQ_CMD_LM_SUSPEND_STATUS
915 * @rsvd: Word boundary padding
917 * @type: Type of suspend (enum pds_lm_suspend_resume_type)
919 struct pds_lm_suspend_status_cmd
{
927 * struct pds_lm_resume_cmd - RESUME command
928 * @opcode: Opcode PDS_LM_CMD_RESUME
929 * @rsvd: Word boundary padding
931 * @type: Type of resume (enum pds_lm_suspend_resume_type)
933 struct pds_lm_resume_cmd
{
941 * struct pds_lm_sg_elem - Transmit scatter-gather (SG) descriptor element
942 * @addr: DMA address of SG element data buffer
943 * @len: Length of SG element data buffer, in bytes
944 * @rsvd: Word boundary padding
946 struct pds_lm_sg_elem
{
953 * struct pds_lm_save_cmd - SAVE command
954 * @opcode: Opcode PDS_LM_CMD_SAVE
955 * @rsvd: Word boundary padding
957 * @rsvd2: Word boundary padding
958 * @sgl_addr: IOVA address of the SGL to dma the device state
959 * @num_sge: Total number of SG elements
961 struct pds_lm_save_cmd
{
971 * struct pds_lm_restore_cmd - RESTORE command
972 * @opcode: Opcode PDS_LM_CMD_RESTORE
973 * @rsvd: Word boundary padding
975 * @rsvd2: Word boundary padding
976 * @sgl_addr: IOVA address of the SGL to dma the device state
977 * @num_sge: Total number of SG elements
979 struct pds_lm_restore_cmd
{
989 * union pds_lm_dev_state - device state information
990 * @words: Device state words
992 union pds_lm_dev_state
{
993 __le32 words
[PDS_LM_DEVICE_STATE_LENGTH
/ sizeof(__le32
)];
996 enum pds_lm_host_vf_status
{
998 PDS_LM_STA_IN_PROGRESS
,
1003 * struct pds_lm_dirty_region_info - Memory region info for STATUS and ENABLE
1004 * @dma_base: Base address of the DMA-contiguous memory region
1005 * @page_count: Number of pages in the memory region
1006 * @page_size_log2: Log2 page size in the memory region
1007 * @rsvd: Word boundary padding
1009 struct pds_lm_dirty_region_info
{
1017 * struct pds_lm_dirty_status_cmd - DIRTY_STATUS command
1018 * @opcode: Opcode PDS_LM_CMD_DIRTY_STATUS
1019 * @rsvd: Word boundary padding
1021 * @max_regions: Capacity of the region info buffer
1022 * @rsvd2: Word boundary padding
1023 * @regions_dma: DMA address of the region info buffer
1025 * The minimum of max_regions (from the command) and num_regions (from the
1026 * completion) of struct pds_lm_dirty_region_info will be written to
1029 * The max_regions may be zero, in which case regions_dma is ignored. In that
1030 * case, the completion will only report the maximum number of regions
1031 * supported by the device, and the number of regions currently enabled.
1033 struct pds_lm_dirty_status_cmd
{
1043 * enum pds_lm_dirty_bmp_type - Type of dirty page bitmap
1044 * @PDS_LM_DIRTY_BMP_TYPE_NONE: No bitmap / disabled
1045 * @PDS_LM_DIRTY_BMP_TYPE_SEQ_ACK: Seq/Ack bitmap representation
1047 enum pds_lm_dirty_bmp_type
{
1048 PDS_LM_DIRTY_BMP_TYPE_NONE
= 0,
1049 PDS_LM_DIRTY_BMP_TYPE_SEQ_ACK
= 1,
1053 * struct pds_lm_dirty_status_comp - STATUS command completion
1054 * @status: Status of the command (enum pds_core_status_code)
1055 * @rsvd: Word boundary padding
1056 * @comp_index: Index in the desc ring for which this is the completion
1057 * @max_regions: Maximum number of regions supported by the device
1058 * @num_regions: Number of regions currently enabled
1059 * @bmp_type: Type of dirty bitmap representation
1060 * @rsvd2: Word boundary padding
1061 * @bmp_type_mask: Mask of supported bitmap types, bit index per type
1062 * @rsvd3: Word boundary padding
1065 * This completion descriptor is used for STATUS, ENABLE, and DISABLE.
1067 struct pds_lm_dirty_status_comp
{
1075 __le32 bmp_type_mask
;
1081 * struct pds_lm_dirty_enable_cmd - DIRTY_ENABLE command
1082 * @opcode: Opcode PDS_LM_CMD_DIRTY_ENABLE
1083 * @rsvd: Word boundary padding
1085 * @bmp_type: Type of dirty bitmap representation
1086 * @num_regions: Number of entries in the region info buffer
1087 * @rsvd2: Word boundary padding
1088 * @regions_dma: DMA address of the region info buffer
1090 * The num_regions must be nonzero, and less than or equal to the maximum
1091 * number of regions supported by the device.
1093 * The memory regions should not overlap.
1095 * The information should be initialized by the driver. The device may modify
1096 * the information on successful completion, such as by size-aligning the
1097 * number of pages in a region.
1099 * The modified number of pages will be greater than or equal to the page count
1100 * given in the enable command, and at least as coarsly aligned as the given
1101 * value. For example, the count might be aligned to a multiple of 64, but
1102 * if the value is already a multiple of 128 or higher, it will not change.
1103 * If the driver requires its own minimum alignment of the number of pages, the
1104 * driver should account for that already in the region info of this command.
1106 * This command uses struct pds_lm_dirty_status_comp for its completion.
1108 struct pds_lm_dirty_enable_cmd
{
1119 * struct pds_lm_dirty_disable_cmd - DIRTY_DISABLE command
1120 * @opcode: Opcode PDS_LM_CMD_DIRTY_DISABLE
1121 * @rsvd: Word boundary padding
1124 * Dirty page tracking will be disabled. This may be called in any state, as
1125 * long as dirty page tracking is supported by the device, to ensure that dirty
1126 * page tracking is disabled.
1128 * This command uses struct pds_lm_dirty_status_comp for its completion. On
1129 * success, num_regions will be zero.
1131 struct pds_lm_dirty_disable_cmd
{
1138 * struct pds_lm_dirty_seq_ack_cmd - DIRTY_READ_SEQ or _WRITE_ACK command
1139 * @opcode: Opcode PDS_LM_CMD_DIRTY_[READ_SEQ|WRITE_ACK]
1140 * @rsvd: Word boundary padding
1142 * @off_bytes: Byte offset in the bitmap
1143 * @len_bytes: Number of bytes to transfer
1144 * @num_sge: Number of DMA scatter gather elements
1145 * @rsvd2: Word boundary padding
1146 * @sgl_addr: DMA address of scatter gather list
1148 * Read bytes from the SEQ bitmap, or write bytes into the ACK bitmap.
1150 * This command treats the entire bitmap as a byte buffer. It does not
1151 * distinguish between guest memory regions. The driver should refer to the
1152 * number of pages in each region, according to PDS_LM_CMD_DIRTY_STATUS, to
1153 * determine the region boundaries in the bitmap. Each region will be
1154 * represented by exactly the number of bits as the page count for that region,
1155 * immediately following the last bit of the previous region.
1157 struct pds_lm_dirty_seq_ack_cmd
{
1169 * struct pds_lm_host_vf_status_cmd - HOST_VF_STATUS command
1170 * @opcode: Opcode PDS_LM_CMD_HOST_VF_STATUS
1171 * @rsvd: Word boundary padding
1173 * @status: Current LM status of host VF driver (enum pds_lm_host_status)
1175 struct pds_lm_host_vf_status_cmd
{
1182 union pds_core_adminq_cmd
{
1186 struct pds_core_client_reg_cmd client_reg
;
1187 struct pds_core_client_unreg_cmd client_unreg
;
1188 struct pds_core_client_request_cmd client_request
;
1190 struct pds_core_lif_identify_cmd lif_ident
;
1191 struct pds_core_lif_init_cmd lif_init
;
1192 struct pds_core_lif_reset_cmd lif_reset
;
1193 struct pds_core_lif_setattr_cmd lif_setattr
;
1194 struct pds_core_lif_getattr_cmd lif_getattr
;
1196 struct pds_core_q_identify_cmd q_ident
;
1197 struct pds_core_q_init_cmd q_init
;
1199 struct pds_vdpa_cmd vdpa
;
1200 struct pds_vdpa_init_cmd vdpa_init
;
1201 struct pds_vdpa_ident_cmd vdpa_ident
;
1202 struct pds_vdpa_status_cmd vdpa_status
;
1203 struct pds_vdpa_setattr_cmd vdpa_setattr
;
1204 struct pds_vdpa_set_features_cmd vdpa_set_features
;
1205 struct pds_vdpa_vq_init_cmd vdpa_vq_init
;
1206 struct pds_vdpa_vq_reset_cmd vdpa_vq_reset
;
1208 struct pds_lm_suspend_cmd lm_suspend
;
1209 struct pds_lm_suspend_status_cmd lm_suspend_status
;
1210 struct pds_lm_resume_cmd lm_resume
;
1211 struct pds_lm_state_size_cmd lm_state_size
;
1212 struct pds_lm_save_cmd lm_save
;
1213 struct pds_lm_restore_cmd lm_restore
;
1214 struct pds_lm_host_vf_status_cmd lm_host_vf_status
;
1215 struct pds_lm_dirty_status_cmd lm_dirty_status
;
1216 struct pds_lm_dirty_enable_cmd lm_dirty_enable
;
1217 struct pds_lm_dirty_disable_cmd lm_dirty_disable
;
1218 struct pds_lm_dirty_seq_ack_cmd lm_dirty_seq_ack
;
1221 union pds_core_adminq_comp
{
1231 struct pds_core_client_reg_comp client_reg
;
1233 struct pds_core_lif_identify_comp lif_ident
;
1234 struct pds_core_lif_init_comp lif_init
;
1235 struct pds_core_lif_setattr_comp lif_setattr
;
1236 struct pds_core_lif_getattr_comp lif_getattr
;
1238 struct pds_core_q_identify_comp q_ident
;
1239 struct pds_core_q_init_comp q_init
;
1241 struct pds_vdpa_vq_init_comp vdpa_vq_init
;
1242 struct pds_vdpa_vq_reset_comp vdpa_vq_reset
;
1244 struct pds_lm_state_size_comp lm_state_size
;
1245 struct pds_lm_dirty_status_comp lm_dirty_status
;
1249 static_assert(sizeof(union pds_core_adminq_cmd
) == 64);
1250 static_assert(sizeof(union pds_core_adminq_comp
) == 16);
1251 static_assert(sizeof(union pds_core_notifyq_comp
) == 64);
1252 #endif /* __CHECKER__ */
1254 /* The color bit is a 'done' bit for the completion descriptors
1255 * where the meaning alternates between '1' and '0' for alternating
1256 * passes through the completion descriptor ring.
1258 static inline bool pdsc_color_match(u8 color
, bool done_color
)
1260 return (!!(color
& PDS_COMP_COLOR_MASK
)) == done_color
;
1264 int pdsc_adminq_post(struct pdsc
*pdsc
,
1265 union pds_core_adminq_cmd
*cmd
,
1266 union pds_core_adminq_comp
*comp
,
1269 #endif /* _PDS_CORE_ADMINQ_H_ */