Skip to content

Commit bf86a01

Browse files
jahay1anguy11
authored andcommitted
idpf: implement remaining IDC RDMA core callbacks and handlers
Implement the idpf_idc_request_reset and idpf_idc_rdma_vc_send_sync callbacks for the rdma core auxiliary driver to issue reset events to the idpf and send (synchronous) virtchnl messages to the control plane respectively. Implement and plumb the reset handler for the opposite flow as well, i.e. when the idpf is resetiing and needs to notify the rdma core auxiliary driver. Reviewed-by: Madhu Chittim <[email protected]> Signed-off-by: Joshua Hay <[email protected]> Signed-off-by: Tatyana Nikolova <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent be91128 commit bf86a01

File tree

5 files changed

+69
-3
lines changed

5 files changed

+69
-3
lines changed

drivers/net/ethernet/intel/idpf/idpf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,5 +893,6 @@ int idpf_idc_init_aux_core_dev(struct idpf_adapter *adapter,
893893
enum iidc_function_type ftype);
894894
void idpf_idc_deinit_core_aux_device(struct iidc_rdma_core_dev_info *cdev_info);
895895
void idpf_idc_deinit_vport_aux_device(struct iidc_rdma_vport_dev_info *vdev_info);
896+
void idpf_idc_issue_reset_event(struct iidc_rdma_core_dev_info *cdev_info);
896897

897898
#endif /* !_IDPF_H_ */

drivers/net/ethernet/intel/idpf/idpf_idc.c

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,38 @@ static void idpf_unplug_aux_dev(struct auxiliary_device *adev)
222222
ida_free(&idpf_idc_ida, adev->id);
223223
}
224224

225+
/**
226+
* idpf_idc_issue_reset_event - Function to handle reset IDC event
227+
* @cdev_info: IDC core device info pointer
228+
*/
229+
void idpf_idc_issue_reset_event(struct iidc_rdma_core_dev_info *cdev_info)
230+
{
231+
enum iidc_rdma_event_type event_type = IIDC_RDMA_EVENT_WARN_RESET;
232+
struct iidc_rdma_core_auxiliary_drv *iadrv;
233+
struct iidc_rdma_event event = { };
234+
struct auxiliary_device *adev;
235+
236+
if (!cdev_info)
237+
/* RDMA is not enabled */
238+
return;
239+
240+
set_bit(event_type, event.type);
241+
242+
device_lock(&cdev_info->adev->dev);
243+
244+
adev = cdev_info->adev;
245+
if (!adev || !adev->dev.driver)
246+
goto unlock;
247+
248+
iadrv = container_of(adev->dev.driver,
249+
struct iidc_rdma_core_auxiliary_drv,
250+
adrv.driver);
251+
if (iadrv->event_handler)
252+
iadrv->event_handler(cdev_info, &event);
253+
unlock:
254+
device_unlock(&cdev_info->adev->dev);
255+
}
256+
225257
/**
226258
* idpf_idc_vport_dev_up - called when CORE is ready for vport aux devs
227259
* @adapter: private data struct
@@ -304,7 +336,16 @@ EXPORT_SYMBOL_GPL(idpf_idc_vport_dev_ctrl);
304336
int idpf_idc_request_reset(struct iidc_rdma_core_dev_info *cdev_info,
305337
enum iidc_rdma_reset_type __always_unused reset_type)
306338
{
307-
return -EOPNOTSUPP;
339+
struct idpf_adapter *adapter = pci_get_drvdata(cdev_info->pdev);
340+
341+
if (!idpf_is_reset_in_prog(adapter)) {
342+
set_bit(IDPF_HR_FUNC_RESET, adapter->flags);
343+
queue_delayed_work(adapter->vc_event_wq,
344+
&adapter->vc_event_task,
345+
msecs_to_jiffies(10));
346+
}
347+
348+
return 0;
308349
}
309350
EXPORT_SYMBOL_GPL(idpf_idc_request_reset);
310351

drivers/net/ethernet/intel/idpf/idpf_lib.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,6 +1789,8 @@ static int idpf_init_hard_reset(struct idpf_adapter *adapter)
17891789
} else if (test_and_clear_bit(IDPF_HR_FUNC_RESET, adapter->flags)) {
17901790
bool is_reset = idpf_is_reset_detected(adapter);
17911791

1792+
idpf_idc_issue_reset_event(adapter->cdev_info);
1793+
17921794
idpf_set_vport_state(adapter);
17931795
idpf_vc_core_deinit(adapter);
17941796
if (!is_reset)

drivers/net/ethernet/intel/idpf/idpf_virtchnl.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3746,6 +3746,27 @@ int idpf_idc_rdma_vc_send_sync(struct iidc_rdma_core_dev_info *cdev_info,
37463746
u8 *send_msg, u16 msg_size,
37473747
u8 *recv_msg, u16 *recv_len)
37483748
{
3749-
return -EOPNOTSUPP;
3749+
struct idpf_adapter *adapter = pci_get_drvdata(cdev_info->pdev);
3750+
struct idpf_vc_xn_params xn_params = { };
3751+
ssize_t reply_sz;
3752+
u16 recv_size;
3753+
3754+
if (!recv_msg || !recv_len || msg_size > IDPF_CTLQ_MAX_BUF_LEN)
3755+
return -EINVAL;
3756+
3757+
recv_size = min_t(u16, *recv_len, IDPF_CTLQ_MAX_BUF_LEN);
3758+
*recv_len = 0;
3759+
xn_params.vc_op = VIRTCHNL2_OP_RDMA;
3760+
xn_params.timeout_ms = IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC;
3761+
xn_params.send_buf.iov_base = send_msg;
3762+
xn_params.send_buf.iov_len = msg_size;
3763+
xn_params.recv_buf.iov_base = recv_msg;
3764+
xn_params.recv_buf.iov_len = recv_size;
3765+
reply_sz = idpf_vc_xn_exec(adapter, &xn_params);
3766+
if (reply_sz < 0)
3767+
return reply_sz;
3768+
*recv_len = reply_sz;
3769+
3770+
return 0;
37503771
}
37513772
EXPORT_SYMBOL_GPL(idpf_idc_rdma_vc_send_sync);

drivers/net/ethernet/intel/idpf/virtchnl2.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ enum virtchnl2_op {
6262
VIRTCHNL2_OP_GET_PTYPE_INFO = 526,
6363
/* Opcode 527 and 528 are reserved for VIRTCHNL2_OP_GET_PTYPE_ID and
6464
* VIRTCHNL2_OP_GET_PTYPE_INFO_RAW.
65-
* Opcodes 529, 530, 531, 532 and 533 are reserved.
6665
*/
66+
VIRTCHNL2_OP_RDMA = 529,
67+
/* Opcodes 530 through 533 are reserved. */
6768
VIRTCHNL2_OP_LOOPBACK = 534,
6869
VIRTCHNL2_OP_ADD_MAC_ADDR = 535,
6970
VIRTCHNL2_OP_DEL_MAC_ADDR = 536,

0 commit comments

Comments
 (0)