Skip to content

Commit bf59b53

Browse files
Michal Swiatkowskianguy11
authored andcommitted
ice: allow calling custom send function in fwlog
Fwlog code needs to communicate with FW. In ice it is done through admin queue command. Allow indirect calling the send function to move the specific admin queue send function from fwlog core code. Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel) Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 4773761 commit bf59b53

File tree

4 files changed

+65
-45
lines changed

4 files changed

+65
-45
lines changed

drivers/net/ethernet/intel/ice/ice_common.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,26 @@ static int ice_wait_for_fw(struct ice_hw *hw, u32 timeout)
984984
return -ETIMEDOUT;
985985
}
986986

987+
static int __fwlog_send_cmd(void *priv, struct libie_aq_desc *desc, void *buf,
988+
u16 size)
989+
{
990+
struct ice_hw *hw = priv;
991+
992+
return ice_aq_send_cmd(hw, desc, buf, size, NULL);
993+
}
994+
995+
static int __fwlog_init(struct ice_hw *hw)
996+
{
997+
struct ice_pf *pf = hw->back;
998+
struct ice_fwlog_api api = {
999+
.pdev = pf->pdev,
1000+
.send_cmd = __fwlog_send_cmd,
1001+
.priv = hw,
1002+
};
1003+
1004+
return ice_fwlog_init(hw, &hw->fwlog, &api);
1005+
}
1006+
9871007
/**
9881008
* ice_init_hw - main hardware initialization routine
9891009
* @hw: pointer to the hardware structure
@@ -992,7 +1012,6 @@ int ice_init_hw(struct ice_hw *hw)
9921012
{
9931013
struct ice_aqc_get_phy_caps_data *pcaps __free(kfree) = NULL;
9941014
void *mac_buf __free(kfree) = NULL;
995-
struct ice_pf *pf = hw->back;
9961015
u16 mac_buf_len;
9971016
int status;
9981017

@@ -1013,7 +1032,7 @@ int ice_init_hw(struct ice_hw *hw)
10131032
if (status)
10141033
goto err_unroll_cqinit;
10151034

1016-
status = ice_fwlog_init(hw, &hw->fwlog, pf->pdev);
1035+
status = __fwlog_init(hw);
10171036
if (status)
10181037
ice_debug(hw, ICE_DBG_FW_LOG, "Error initializing FW logging: %d\n",
10191038
status);

drivers/net/ethernet/intel/ice/ice_debugfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,14 @@ ice_debugfs_enable_write(struct file *filp, const char __user *buf,
350350
else
351351
hw->fwlog.cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
352352

353-
ret = ice_fwlog_set(hw, &hw->fwlog.cfg);
353+
ret = ice_fwlog_set(&hw->fwlog, &hw->fwlog.cfg);
354354
if (ret)
355355
goto enable_write_error;
356356

357357
if (enable)
358-
ret = ice_fwlog_register(hw, &hw->fwlog);
358+
ret = ice_fwlog_register(&hw->fwlog);
359359
else
360-
ret = ice_fwlog_unregister(hw, &hw->fwlog);
360+
ret = ice_fwlog_unregister(&hw->fwlog);
361361

362362
if (ret)
363363
goto enable_write_error;

drivers/net/ethernet/intel/ice/ice_fwlog.c

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ static bool ice_fwlog_supported(struct ice_fwlog *fwlog)
137137

138138
/**
139139
* ice_aq_fwlog_get - Get the current firmware logging configuration (0xFF32)
140-
* @hw: pointer to the HW structure
140+
* @fwlog: pointer to the fwlog structure
141141
* @cfg: firmware logging configuration to populate
142142
*/
143-
static int ice_aq_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
143+
static int ice_aq_fwlog_get(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
144144
{
145145
struct ice_aqc_fw_log_cfg_resp *fw_modules;
146146
struct ice_aqc_fw_log *cmd;
@@ -161,17 +161,17 @@ static int ice_aq_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
161161

162162
cmd->cmd_flags = ICE_AQC_FW_LOG_AQ_QUERY;
163163

164-
status = ice_aq_send_cmd(hw, &desc, buf, ICE_AQ_MAX_BUF_LEN, NULL);
164+
status = fwlog->send_cmd(fwlog->priv, &desc, buf, ICE_AQ_MAX_BUF_LEN);
165165
if (status) {
166-
dev_dbg(&hw->fwlog.pdev->dev, "Failed to get FW log configuration\n");
166+
dev_dbg(&fwlog->pdev->dev, "Failed to get FW log configuration\n");
167167
goto status_out;
168168
}
169169

170170
module_id_cnt = le16_to_cpu(cmd->ops.cfg.mdl_cnt);
171171
if (module_id_cnt < ICE_AQC_FW_LOG_ID_MAX) {
172-
dev_dbg(&hw->fwlog.pdev->dev, "FW returned less than the expected number of FW log module IDs\n");
172+
dev_dbg(&fwlog->pdev->dev, "FW returned less than the expected number of FW log module IDs\n");
173173
} else if (module_id_cnt > ICE_AQC_FW_LOG_ID_MAX) {
174-
dev_dbg(&hw->fwlog.pdev->dev, "FW returned more than expected number of FW log module IDs, setting module_id_cnt to software expected max %u\n",
174+
dev_dbg(&fwlog->pdev->dev, "FW returned more than expected number of FW log module IDs, setting module_id_cnt to software expected max %u\n",
175175
ICE_AQC_FW_LOG_ID_MAX);
176176
module_id_cnt = ICE_AQC_FW_LOG_ID_MAX;
177177
}
@@ -201,7 +201,6 @@ static int ice_aq_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
201201

202202
/**
203203
* ice_fwlog_set_supported - Set if FW logging is supported by FW
204-
* @hw: pointer to the HW struct
205204
* @fwlog: pointer to the fwlog structure
206205
*
207206
* If FW returns success to the ice_aq_fwlog_get call then it supports FW
@@ -210,7 +209,7 @@ static int ice_aq_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
210209
* This function is only meant to be called during driver init to determine if
211210
* the FW support FW logging.
212211
*/
213-
static void ice_fwlog_set_supported(struct ice_hw *hw, struct ice_fwlog *fwlog)
212+
static void ice_fwlog_set_supported(struct ice_fwlog *fwlog)
214213
{
215214
struct ice_fwlog_cfg *cfg;
216215
int status;
@@ -221,7 +220,7 @@ static void ice_fwlog_set_supported(struct ice_hw *hw, struct ice_fwlog *fwlog)
221220
if (!cfg)
222221
return;
223222

224-
status = ice_aq_fwlog_get(hw, cfg);
223+
status = ice_aq_fwlog_get(fwlog, cfg);
225224
if (status)
226225
dev_dbg(&fwlog->pdev->dev, "ice_aq_fwlog_get failed, FW logging is not supported on this version of FW, status %d\n",
227226
status);
@@ -235,26 +234,26 @@ static void ice_fwlog_set_supported(struct ice_hw *hw, struct ice_fwlog *fwlog)
235234
* ice_fwlog_init - Initialize FW logging configuration
236235
* @hw: pointer to the HW structure
237236
* @fwlog: pointer to the fwlog structure
238-
* @pdev: pointer to the pci dev used in dev_warn()
237+
* @api: api structure to init fwlog
239238
*
240239
* This function should be called on driver initialization during
241240
* ice_init_hw().
242241
*/
243242
int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
244-
struct pci_dev *pdev)
243+
struct ice_fwlog_api *api)
245244
{
246245
/* only support fw log commands on PF 0 */
247246
if (hw->bus.func)
248247
return -EINVAL;
249248

250-
ice_fwlog_set_supported(hw, fwlog);
251-
fwlog->pdev = pdev;
249+
fwlog->api = *api;
250+
ice_fwlog_set_supported(fwlog);
252251

253252
if (ice_fwlog_supported(fwlog)) {
254253
int status;
255254

256255
/* read the current config from the FW and store it */
257-
status = ice_aq_fwlog_get(hw, &fwlog->cfg);
256+
status = ice_aq_fwlog_get(fwlog, &fwlog->cfg);
258257
if (status)
259258
return status;
260259

@@ -307,7 +306,7 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
307306
* for the next driver load
308307
*/
309308
fwlog->cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA;
310-
status = ice_fwlog_set(hw, &fwlog->cfg);
309+
status = ice_fwlog_set(fwlog, &fwlog->cfg);
311310
if (status)
312311
dev_warn(&fwlog->pdev->dev, "Unable to turn off FW logging, status: %d\n",
313312
status);
@@ -316,7 +315,7 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
316315

317316
pf->ice_debugfs_pf_fwlog_modules = NULL;
318317

319-
status = ice_fwlog_unregister(hw, fwlog);
318+
status = ice_fwlog_unregister(fwlog);
320319
if (status)
321320
dev_warn(&fwlog->pdev->dev, "Unable to unregister FW logging, status: %d\n",
322321
status);
@@ -329,15 +328,16 @@ void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog)
329328

330329
/**
331330
* ice_aq_fwlog_set - Set FW logging configuration AQ command (0xFF30)
332-
* @hw: pointer to the HW structure
331+
* @fwlog: pointer to the fwlog structure
333332
* @entries: entries to configure
334333
* @num_entries: number of @entries
335334
* @options: options from ice_fwlog_cfg->options structure
336335
* @log_resolution: logging resolution
337336
*/
338337
static int
339-
ice_aq_fwlog_set(struct ice_hw *hw, struct ice_fwlog_module_entry *entries,
340-
u16 num_entries, u16 options, u16 log_resolution)
338+
ice_aq_fwlog_set(struct ice_fwlog *fwlog,
339+
struct ice_fwlog_module_entry *entries, u16 num_entries,
340+
u16 options, u16 log_resolution)
341341
{
342342
struct ice_aqc_fw_log_cfg_resp *fw_modules;
343343
struct ice_aqc_fw_log *cmd;
@@ -369,9 +369,8 @@ ice_aq_fwlog_set(struct ice_hw *hw, struct ice_fwlog_module_entry *entries,
369369
if (options & ICE_FWLOG_OPTION_UART_ENA)
370370
cmd->cmd_flags |= ICE_AQC_FW_LOG_CONF_UART_EN;
371371

372-
status = ice_aq_send_cmd(hw, &desc, fw_modules,
373-
sizeof(*fw_modules) * num_entries,
374-
NULL);
372+
status = fwlog->send_cmd(fwlog->priv, &desc, fw_modules,
373+
sizeof(*fw_modules) * num_entries);
375374

376375
kfree(fw_modules);
377376

@@ -380,7 +379,7 @@ ice_aq_fwlog_set(struct ice_hw *hw, struct ice_fwlog_module_entry *entries,
380379

381380
/**
382381
* ice_fwlog_set - Set the firmware logging settings
383-
* @hw: pointer to the HW structure
382+
* @fwlog: pointer to the fwlog structure
384383
* @cfg: config used to set firmware logging
385384
*
386385
* This function should be called whenever the driver needs to set the firmware
@@ -391,22 +390,22 @@ ice_aq_fwlog_set(struct ice_hw *hw, struct ice_fwlog_module_entry *entries,
391390
* ice_fwlog_register. Note, that ice_fwlog_register does not need to be called
392391
* for init.
393392
*/
394-
int ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg)
393+
int ice_fwlog_set(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg)
395394
{
396-
if (!ice_fwlog_supported(&hw->fwlog))
395+
if (!ice_fwlog_supported(fwlog))
397396
return -EOPNOTSUPP;
398397

399-
return ice_aq_fwlog_set(hw, cfg->module_entries,
398+
return ice_aq_fwlog_set(fwlog, cfg->module_entries,
400399
ICE_AQC_FW_LOG_ID_MAX, cfg->options,
401400
cfg->log_resolution);
402401
}
403402

404403
/**
405404
* ice_aq_fwlog_register - Register PF for firmware logging events (0xFF31)
406-
* @hw: pointer to the HW structure
405+
* @fwlog: pointer to the fwlog structure
407406
* @reg: true to register and false to unregister
408407
*/
409-
static int ice_aq_fwlog_register(struct ice_hw *hw, bool reg)
408+
static int ice_aq_fwlog_register(struct ice_fwlog *fwlog, bool reg)
410409
{
411410
struct ice_aqc_fw_log *cmd;
412411
struct libie_aq_desc desc;
@@ -417,25 +416,24 @@ static int ice_aq_fwlog_register(struct ice_hw *hw, bool reg)
417416
if (reg)
418417
cmd->cmd_flags = ICE_AQC_FW_LOG_AQ_REGISTER;
419418

420-
return ice_aq_send_cmd(hw, &desc, NULL, 0, NULL);
419+
return fwlog->send_cmd(fwlog->priv, &desc, NULL, 0);
421420
}
422421

423422
/**
424423
* ice_fwlog_register - Register the PF for firmware logging
425-
* @hw: pointer to the HW structure
426424
* @fwlog: pointer to the fwlog structure
427425
*
428426
* After this call the PF will start to receive firmware logging based on the
429427
* configuration set in ice_fwlog_set.
430428
*/
431-
int ice_fwlog_register(struct ice_hw *hw, struct ice_fwlog *fwlog)
429+
int ice_fwlog_register(struct ice_fwlog *fwlog)
432430
{
433431
int status;
434432

435433
if (!ice_fwlog_supported(fwlog))
436434
return -EOPNOTSUPP;
437435

438-
status = ice_aq_fwlog_register(hw, true);
436+
status = ice_aq_fwlog_register(fwlog, true);
439437
if (status)
440438
dev_dbg(&fwlog->pdev->dev, "Failed to register for firmware logging events over ARQ\n");
441439
else
@@ -446,17 +444,16 @@ int ice_fwlog_register(struct ice_hw *hw, struct ice_fwlog *fwlog)
446444

447445
/**
448446
* ice_fwlog_unregister - Unregister the PF from firmware logging
449-
* @hw: pointer to the HW structure
450447
* @fwlog: pointer to the fwlog structure
451448
*/
452-
int ice_fwlog_unregister(struct ice_hw *hw, struct ice_fwlog *fwlog)
449+
int ice_fwlog_unregister(struct ice_fwlog *fwlog)
453450
{
454451
int status;
455452

456453
if (!ice_fwlog_supported(fwlog))
457454
return -EOPNOTSUPP;
458455

459-
status = ice_aq_fwlog_register(hw, false);
456+
status = ice_aq_fwlog_register(fwlog, false);
460457
if (status)
461458
dev_dbg(&fwlog->pdev->dev, "Failed to unregister from firmware logging events over ARQ\n");
462459
else

drivers/net/ethernet/intel/ice/ice_fwlog.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,21 @@ struct ice_fwlog {
6868
struct ice_fwlog_cfg cfg;
6969
bool supported; /* does hardware support FW logging? */
7070
struct ice_fwlog_ring ring;
71-
struct pci_dev *pdev;
71+
struct_group_tagged(ice_fwlog_api, api,
72+
struct pci_dev *pdev;
73+
int (*send_cmd)(void *, struct libie_aq_desc *, void *, u16);
74+
void *priv;
75+
);
7276
};
7377

7478
bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings);
7579
void ice_fwlog_ring_increment(u16 *item, u16 size);
7680
int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog *fwlog,
77-
struct pci_dev *pdev);
81+
struct ice_fwlog_api *api);
7882
void ice_fwlog_deinit(struct ice_hw *hw, struct ice_fwlog *fwlog);
79-
int ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
80-
int ice_fwlog_register(struct ice_hw *hw, struct ice_fwlog *fwlog);
81-
int ice_fwlog_unregister(struct ice_hw *hw, struct ice_fwlog *fwlog);
83+
int ice_fwlog_set(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg);
84+
int ice_fwlog_register(struct ice_fwlog *fwlog);
85+
int ice_fwlog_unregister(struct ice_fwlog *fwlog);
8286
void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index);
8387
void ice_get_fwlog_data(struct ice_fwlog *fwlog, u8 *buf, u16 len);
8488
#endif /* _ICE_FWLOG_H_ */

0 commit comments

Comments
 (0)