]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
idpf: generalize mailbox API
authorPavan Kumar Linga <pavan.kumar.linga@intel.com>
Thu, 13 Nov 2025 00:41:43 +0000 (16:41 -0800)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Thu, 22 Jan 2026 22:00:13 +0000 (14:00 -0800)
Add a control queue parameter to all mailbox APIs in order to make use
of those APIs for non-default mailbox as well.

Signed-off-by: Anton Nadezhdin <anton.nadezhdin@intel.com>
Reviewed-by: Madhu Chittim <madhu.chittim@intel.com>
Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
Signed-off-by: Joshua Hay <joshua.a.hay@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: Samuel Salin <Samuel.salin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/idpf/idpf_lib.c
drivers/net/ethernet/intel/idpf/idpf_vf_dev.c
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
drivers/net/ethernet/intel/idpf/idpf_virtchnl.h

index 63855dcb609dff66982c5ca40fb7acf7ee548aeb..94da5fbd56f1e13753d8209b7b0db02900551d70 100644 (file)
@@ -1384,7 +1384,7 @@ void idpf_mbx_task(struct work_struct *work)
                queue_delayed_work(adapter->mbx_wq, &adapter->mbx_task,
                                   usecs_to_jiffies(300));
 
-       idpf_recv_mb_msg(adapter);
+       idpf_recv_mb_msg(adapter, adapter->hw.arq);
 }
 
 /**
index 8c2008477621ab7edbb21b2d0fdc8f7d50a61af3..7527b967e2e73230197182f3ef58f4f5fdfb7877 100644 (file)
@@ -158,7 +158,8 @@ static void idpf_vf_trigger_reset(struct idpf_adapter *adapter,
        /* Do not send VIRTCHNL2_OP_RESET_VF message on driver unload */
        if (trig_cause == IDPF_HR_FUNC_RESET &&
            !test_bit(IDPF_REMOVE_IN_PROG, adapter->flags))
-               idpf_send_mb_msg(adapter, VIRTCHNL2_OP_RESET_VF, 0, NULL, 0);
+               idpf_send_mb_msg(adapter, adapter->hw.asq,
+                                VIRTCHNL2_OP_RESET_VF, 0, NULL, 0);
 }
 
 /**
index 1a9b82695c5fb7e6b832d35657196b411f6e98f1..d46affaf7185c86f3b3730813addb4d7edaa9c40 100644 (file)
@@ -117,13 +117,15 @@ static void idpf_recv_event_msg(struct idpf_adapter *adapter,
 
 /**
  * idpf_mb_clean - Reclaim the send mailbox queue entries
- * @adapter: Driver specific private structure
+ * @adapter: driver specific private structure
+ * @asq: send control queue info
  *
  * Reclaim the send mailbox queue entries to be used to send further messages
  *
- * Returns 0 on success, negative on failure
+ * Return: 0 on success, negative on failure
  */
-static int idpf_mb_clean(struct idpf_adapter *adapter)
+static int idpf_mb_clean(struct idpf_adapter *adapter,
+                        struct idpf_ctlq_info *asq)
 {
        u16 i, num_q_msg = IDPF_DFLT_MBX_Q_LEN;
        struct idpf_ctlq_msg **q_msg;
@@ -134,7 +136,7 @@ static int idpf_mb_clean(struct idpf_adapter *adapter)
        if (!q_msg)
                return -ENOMEM;
 
-       err = idpf_ctlq_clean_sq(adapter->hw.asq, &num_q_msg, q_msg);
+       err = idpf_ctlq_clean_sq(asq, &num_q_msg, q_msg);
        if (err)
                goto err_kfree;
 
@@ -206,7 +208,8 @@ static void idpf_prepare_ptp_mb_msg(struct idpf_adapter *adapter, u32 op,
 
 /**
  * idpf_send_mb_msg - Send message over mailbox
- * @adapter: Driver specific private structure
+ * @adapter: driver specific private structure
+ * @asq: control queue to send message to
  * @op: virtchnl opcode
  * @msg_size: size of the payload
  * @msg: pointer to buffer holding the payload
@@ -214,10 +217,10 @@ static void idpf_prepare_ptp_mb_msg(struct idpf_adapter *adapter, u32 op,
  *
  * Will prepare the control queue message and initiates the send api
  *
- * Returns 0 on success, negative on failure
+ * Return: 0 on success, negative on failure
  */
-int idpf_send_mb_msg(struct idpf_adapter *adapter, u32 op,
-                    u16 msg_size, u8 *msg, u16 cookie)
+int idpf_send_mb_msg(struct idpf_adapter *adapter, struct idpf_ctlq_info *asq,
+                    u32 op, u16 msg_size, u8 *msg, u16 cookie)
 {
        struct idpf_ctlq_msg *ctlq_msg;
        struct idpf_dma_mem *dma_mem;
@@ -231,7 +234,7 @@ int idpf_send_mb_msg(struct idpf_adapter *adapter, u32 op,
        if (idpf_is_reset_detected(adapter))
                return 0;
 
-       err = idpf_mb_clean(adapter);
+       err = idpf_mb_clean(adapter, asq);
        if (err)
                return err;
 
@@ -267,7 +270,7 @@ int idpf_send_mb_msg(struct idpf_adapter *adapter, u32 op,
        ctlq_msg->ctx.indirect.payload = dma_mem;
        ctlq_msg->ctx.sw_cookie.data = cookie;
 
-       err = idpf_ctlq_send(&adapter->hw, adapter->hw.asq, 1, ctlq_msg);
+       err = idpf_ctlq_send(&adapter->hw, asq, 1, ctlq_msg);
        if (err)
                goto send_error;
 
@@ -463,7 +466,7 @@ ssize_t idpf_vc_xn_exec(struct idpf_adapter *adapter,
        cookie = FIELD_PREP(IDPF_VC_XN_SALT_M, xn->salt) |
                 FIELD_PREP(IDPF_VC_XN_IDX_M, xn->idx);
 
-       retval = idpf_send_mb_msg(adapter, params->vc_op,
+       retval = idpf_send_mb_msg(adapter, adapter->hw.asq, params->vc_op,
                                  send_buf->iov_len, send_buf->iov_base,
                                  cookie);
        if (retval) {
@@ -662,12 +665,14 @@ out_unlock:
 
 /**
  * idpf_recv_mb_msg - Receive message over mailbox
- * @adapter: Driver specific private structure
+ * @adapter: driver specific private structure
+ * @arq: control queue to receive message from
+ *
+ * Will receive control queue message and posts the receive buffer.
  *
- * Will receive control queue message and posts the receive buffer. Returns 0
- * on success and negative on failure.
+ * Return: 0 on success and negative on failure.
  */
-int idpf_recv_mb_msg(struct idpf_adapter *adapter)
+int idpf_recv_mb_msg(struct idpf_adapter *adapter, struct idpf_ctlq_info *arq)
 {
        struct idpf_ctlq_msg ctlq_msg;
        struct idpf_dma_mem *dma_mem;
@@ -679,7 +684,7 @@ int idpf_recv_mb_msg(struct idpf_adapter *adapter)
                 * actually received on num_recv.
                 */
                num_recv = 1;
-               err = idpf_ctlq_recv(adapter->hw.arq, &num_recv, &ctlq_msg);
+               err = idpf_ctlq_recv(arq, &num_recv, &ctlq_msg);
                if (err || !num_recv)
                        break;
 
@@ -695,8 +700,7 @@ int idpf_recv_mb_msg(struct idpf_adapter *adapter)
                else
                        err = idpf_vc_xn_forward_reply(adapter, &ctlq_msg);
 
-               post_err = idpf_ctlq_post_rx_buffs(&adapter->hw,
-                                                  adapter->hw.arq,
+               post_err = idpf_ctlq_post_rx_buffs(&adapter->hw, arq,
                                                   &num_recv, &dma_mem);
 
                /* If post failed clear the only buffer we supplied */
@@ -3398,7 +3402,7 @@ int idpf_init_dflt_mbx(struct idpf_adapter *adapter)
 void idpf_deinit_dflt_mbx(struct idpf_adapter *adapter)
 {
        if (adapter->hw.arq && adapter->hw.asq) {
-               idpf_mb_clean(adapter);
+               idpf_mb_clean(adapter, adapter->hw.asq);
                idpf_ctlq_deinit(&adapter->hw);
        }
        adapter->hw.arq = NULL;
index 3e5a22bbeabd12a0ab1f4af64516e5222d50dc29..fe065911ad5af47d4ed32c3119d2783dd497db80 100644 (file)
@@ -123,9 +123,9 @@ bool idpf_sideband_action_ena(struct idpf_vport *vport,
                              struct ethtool_rx_flow_spec *fsp);
 unsigned int idpf_fsteer_max_rules(struct idpf_vport *vport);
 
-int idpf_recv_mb_msg(struct idpf_adapter *adapter);
-int idpf_send_mb_msg(struct idpf_adapter *adapter, u32 op,
-                    u16 msg_size, u8 *msg, u16 cookie);
+int idpf_recv_mb_msg(struct idpf_adapter *adapter, struct idpf_ctlq_info *arq);
+int idpf_send_mb_msg(struct idpf_adapter *adapter, struct idpf_ctlq_info *asq,
+                    u32 op, u16 msg_size, u8 *msg, u16 cookie);
 
 struct idpf_queue_ptr {
        enum virtchnl2_queue_type       type;