Skip to content

Commit 62c1bff

Browse files
Souradeep Chakrabartidavem330
authored andcommitted
net: mana: Configure hwc timeout from hardware
At present hwc timeout value is a fixed value. This patch sets the hwc timeout from the hardware. It now uses a new hardware capability GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECONFIG to query and set the value in hwc_timeout. Signed-off-by: Souradeep Chakrabarti <[email protected]> Reviewed-by: Jesse Brandeburg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 58e7012 commit 62c1bff

File tree

4 files changed

+76
-3
lines changed

4 files changed

+76
-3
lines changed

drivers/net/ethernet/microsoft/mana/gdma_main.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,25 @@ static int mana_gd_query_max_resources(struct pci_dev *pdev)
106106
return 0;
107107
}
108108

109+
static int mana_gd_query_hwc_timeout(struct pci_dev *pdev, u32 *timeout_val)
110+
{
111+
struct gdma_context *gc = pci_get_drvdata(pdev);
112+
struct gdma_query_hwc_timeout_resp resp = {};
113+
struct gdma_query_hwc_timeout_req req = {};
114+
int err;
115+
116+
mana_gd_init_req_hdr(&req.hdr, GDMA_QUERY_HWC_TIMEOUT,
117+
sizeof(req), sizeof(resp));
118+
req.timeout_ms = *timeout_val;
119+
err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp);
120+
if (err || resp.hdr.status)
121+
return err ? err : -EPROTO;
122+
123+
*timeout_val = resp.timeout_ms;
124+
125+
return 0;
126+
}
127+
109128
static int mana_gd_detect_devices(struct pci_dev *pdev)
110129
{
111130
struct gdma_context *gc = pci_get_drvdata(pdev);
@@ -882,8 +901,10 @@ int mana_gd_verify_vf_version(struct pci_dev *pdev)
882901
struct gdma_context *gc = pci_get_drvdata(pdev);
883902
struct gdma_verify_ver_resp resp = {};
884903
struct gdma_verify_ver_req req = {};
904+
struct hw_channel_context *hwc;
885905
int err;
886906

907+
hwc = gc->hwc.driver_data;
887908
mana_gd_init_req_hdr(&req.hdr, GDMA_VERIFY_VF_DRIVER_VERSION,
888909
sizeof(req), sizeof(resp));
889910

@@ -910,7 +931,14 @@ int mana_gd_verify_vf_version(struct pci_dev *pdev)
910931
err, resp.hdr.status);
911932
return err ? err : -EPROTO;
912933
}
913-
934+
if (resp.pf_cap_flags1 & GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECONFIG) {
935+
err = mana_gd_query_hwc_timeout(pdev, &hwc->hwc_timeout);
936+
if (err) {
937+
dev_err(gc->dev, "Failed to set the hwc timeout %d\n", err);
938+
return err;
939+
}
940+
dev_dbg(gc->dev, "set the hwc timeout to %u\n", hwc->hwc_timeout);
941+
}
914942
return 0;
915943
}
916944

drivers/net/ethernet/microsoft/mana/hw_channel.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,25 @@ static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self,
174174
complete(&hwc->hwc_init_eqe_comp);
175175
break;
176176

177+
case GDMA_EQE_HWC_SOC_RECONFIG_DATA:
178+
type_data.as_uint32 = event->details[0];
179+
type = type_data.type;
180+
val = type_data.value;
181+
182+
switch (type) {
183+
case HWC_DATA_CFG_HWC_TIMEOUT:
184+
hwc->hwc_timeout = val;
185+
break;
186+
187+
default:
188+
dev_warn(hwc->dev, "Received unknown reconfig type %u\n", type);
189+
break;
190+
}
191+
192+
break;
193+
177194
default:
195+
dev_warn(hwc->dev, "Received unknown gdma event %u\n", event->type);
178196
/* Ignore unknown events, which should never happen. */
179197
break;
180198
}
@@ -696,6 +714,7 @@ int mana_hwc_create_channel(struct gdma_context *gc)
696714
gd->driver_data = hwc;
697715
hwc->gdma_dev = gd;
698716
hwc->dev = gc->dev;
717+
hwc->hwc_timeout = HW_CHANNEL_WAIT_RESOURCE_TIMEOUT_MS;
699718

700719
/* HWC's instance number is always 0. */
701720
gd->dev_id.as_uint32 = 0;
@@ -770,6 +789,8 @@ void mana_hwc_destroy_channel(struct gdma_context *gc)
770789
hwc->gdma_dev->doorbell = INVALID_DOORBELL;
771790
hwc->gdma_dev->pdid = INVALID_PDID;
772791

792+
hwc->hwc_timeout = 0;
793+
773794
kfree(hwc);
774795
gc->hwc.driver_data = NULL;
775796
gc->hwc.gdma_context = NULL;
@@ -825,7 +846,8 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,
825846
goto out;
826847
}
827848

828-
if (!wait_for_completion_timeout(&ctx->comp_event, 30 * HZ)) {
849+
if (!wait_for_completion_timeout(&ctx->comp_event,
850+
(msecs_to_jiffies(hwc->hwc_timeout) * HZ))) {
829851
dev_err(hwc->dev, "HWC: Request timed out!\n");
830852
err = -ETIMEDOUT;
831853
goto out;

include/net/mana/gdma.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ enum gdma_request_type {
3333
GDMA_DESTROY_PD = 30,
3434
GDMA_CREATE_MR = 31,
3535
GDMA_DESTROY_MR = 32,
36+
GDMA_QUERY_HWC_TIMEOUT = 84, /* 0x54 */
3637
};
3738

3839
#define GDMA_RESOURCE_DOORBELL_PAGE 27
@@ -57,6 +58,8 @@ enum gdma_eqe_type {
5758
GDMA_EQE_HWC_INIT_EQ_ID_DB = 129,
5859
GDMA_EQE_HWC_INIT_DATA = 130,
5960
GDMA_EQE_HWC_INIT_DONE = 131,
61+
GDMA_EQE_HWC_SOC_RECONFIG = 132,
62+
GDMA_EQE_HWC_SOC_RECONFIG_DATA = 133,
6063
};
6164

6265
enum {
@@ -531,10 +534,12 @@ enum {
531534
* so the driver is able to reliably support features like busy_poll.
532535
*/
533536
#define GDMA_DRV_CAP_FLAG_1_NAPI_WKDONE_FIX BIT(2)
537+
#define GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECONFIG BIT(3)
534538

535539
#define GDMA_DRV_CAP_FLAGS1 \
536540
(GDMA_DRV_CAP_FLAG_1_EQ_SHARING_MULTI_VPORT | \
537-
GDMA_DRV_CAP_FLAG_1_NAPI_WKDONE_FIX)
541+
GDMA_DRV_CAP_FLAG_1_NAPI_WKDONE_FIX | \
542+
GDMA_DRV_CAP_FLAG_1_HWC_TIMEOUT_RECONFIG)
538543

539544
#define GDMA_DRV_CAP_FLAGS2 0
540545

@@ -664,6 +669,19 @@ struct gdma_disable_queue_req {
664669
u32 alloc_res_id_on_creation;
665670
}; /* HW DATA */
666671

672+
/* GDMA_QUERY_HWC_TIMEOUT */
673+
struct gdma_query_hwc_timeout_req {
674+
struct gdma_req_hdr hdr;
675+
u32 timeout_ms;
676+
u32 reserved;
677+
};
678+
679+
struct gdma_query_hwc_timeout_resp {
680+
struct gdma_resp_hdr hdr;
681+
u32 timeout_ms;
682+
u32 reserved;
683+
};
684+
667685
enum atb_page_size {
668686
ATB_PAGE_SIZE_4K,
669687
ATB_PAGE_SIZE_8K,

include/net/mana/hw_channel.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
#define HWC_INIT_DATA_PF_DEST_RQ_ID 10
2424
#define HWC_INIT_DATA_PF_DEST_CQ_ID 11
2525

26+
#define HWC_DATA_CFG_HWC_TIMEOUT 1
27+
28+
#define HW_CHANNEL_WAIT_RESOURCE_TIMEOUT_MS 30000
29+
2630
/* Structures labeled with "HW DATA" are exchanged with the hardware. All of
2731
* them are naturally aligned and hence don't need __packed.
2832
*/
@@ -182,6 +186,7 @@ struct hw_channel_context {
182186

183187
u32 pf_dest_vrq_id;
184188
u32 pf_dest_vrcq_id;
189+
u32 hwc_timeout;
185190

186191
struct hwc_caller_ctx *caller_ctx;
187192
};

0 commit comments

Comments
 (0)