Skip to content

Commit bab6c86

Browse files
committed
Merge branch 'octeon_ep-max-rx'
Shinas Rasheed says: ==================== Get max rx packet length and solve Patchsets which resolve observed style issues in control net source files, and also implements get mtu control net api to fetch max mtu value from firmware Changes: V2: - Introduced a patch to resolve style issues as mentioned in V1 - Removed OCTEP_MAX_MTU macro, as it is redundant. V1: https://lore.kernel.org/all/20231121191224.2489474-1-srasheed@marvell.com/ ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 1ad04b7 + 0a5f853 commit bab6c86

File tree

4 files changed

+113
-66
lines changed

4 files changed

+113
-66
lines changed

drivers/net/ethernet/marvell/octeon_ep/octep_config.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545

4646
/* Minimum MTU supported by Octeon network interface */
4747
#define OCTEP_MIN_MTU ETH_MIN_MTU
48-
/* Maximum MTU supported by Octeon interface*/
49-
#define OCTEP_MAX_MTU (10000 - (ETH_HLEN + ETH_FCS_LEN))
5048
/* Default MTU */
5149
#define OCTEP_DEFAULT_MTU 1500
5250

drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ int octep_ctrl_net_init(struct octep_device *oct)
122122

123123
int octep_ctrl_net_get_link_status(struct octep_device *oct, int vfid)
124124
{
125-
struct octep_ctrl_net_wait_data d = {0};
125+
struct octep_ctrl_net_wait_data d = {};
126126
struct octep_ctrl_net_h2f_req *req = &d.data.req;
127127
int err;
128128

@@ -139,7 +139,7 @@ int octep_ctrl_net_get_link_status(struct octep_device *oct, int vfid)
139139
int octep_ctrl_net_set_link_status(struct octep_device *oct, int vfid, bool up,
140140
bool wait_for_response)
141141
{
142-
struct octep_ctrl_net_wait_data d = {0};
142+
struct octep_ctrl_net_wait_data d = {};
143143
struct octep_ctrl_net_h2f_req *req = &d.data.req;
144144

145145
init_send_req(&d.msg, req, state_sz, vfid);
@@ -154,7 +154,7 @@ int octep_ctrl_net_set_link_status(struct octep_device *oct, int vfid, bool up,
154154
int octep_ctrl_net_set_rx_state(struct octep_device *oct, int vfid, bool up,
155155
bool wait_for_response)
156156
{
157-
struct octep_ctrl_net_wait_data d = {0};
157+
struct octep_ctrl_net_wait_data d = {};
158158
struct octep_ctrl_net_h2f_req *req = &d.data.req;
159159

160160
init_send_req(&d.msg, req, state_sz, vfid);
@@ -168,7 +168,7 @@ int octep_ctrl_net_set_rx_state(struct octep_device *oct, int vfid, bool up,
168168

169169
int octep_ctrl_net_get_mac_addr(struct octep_device *oct, int vfid, u8 *addr)
170170
{
171-
struct octep_ctrl_net_wait_data d = {0};
171+
struct octep_ctrl_net_wait_data d = {};
172172
struct octep_ctrl_net_h2f_req *req = &d.data.req;
173173
int err;
174174

@@ -187,7 +187,7 @@ int octep_ctrl_net_get_mac_addr(struct octep_device *oct, int vfid, u8 *addr)
187187
int octep_ctrl_net_set_mac_addr(struct octep_device *oct, int vfid, u8 *addr,
188188
bool wait_for_response)
189189
{
190-
struct octep_ctrl_net_wait_data d = {0};
190+
struct octep_ctrl_net_wait_data d = {};
191191
struct octep_ctrl_net_h2f_req *req = &d.data.req;
192192

193193
init_send_req(&d.msg, req, mac_sz, vfid);
@@ -198,10 +198,28 @@ int octep_ctrl_net_set_mac_addr(struct octep_device *oct, int vfid, u8 *addr,
198198
return octep_send_mbox_req(oct, &d, wait_for_response);
199199
}
200200

201+
int octep_ctrl_net_get_mtu(struct octep_device *oct, int vfid)
202+
{
203+
struct octep_ctrl_net_wait_data d = {};
204+
struct octep_ctrl_net_h2f_req *req;
205+
int err;
206+
207+
req = &d.data.req;
208+
init_send_req(&d.msg, req, mtu_sz, vfid);
209+
req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_MTU;
210+
req->mtu.cmd = OCTEP_CTRL_NET_CMD_GET;
211+
212+
err = octep_send_mbox_req(oct, &d, true);
213+
if (err < 0)
214+
return err;
215+
216+
return d.data.resp.mtu.val;
217+
}
218+
201219
int octep_ctrl_net_set_mtu(struct octep_device *oct, int vfid, int mtu,
202220
bool wait_for_response)
203221
{
204-
struct octep_ctrl_net_wait_data d = {0};
222+
struct octep_ctrl_net_wait_data d = {};
205223
struct octep_ctrl_net_h2f_req *req = &d.data.req;
206224

207225
init_send_req(&d.msg, req, mtu_sz, vfid);
@@ -216,7 +234,7 @@ int octep_ctrl_net_get_if_stats(struct octep_device *oct, int vfid,
216234
struct octep_iface_rx_stats *rx_stats,
217235
struct octep_iface_tx_stats *tx_stats)
218236
{
219-
struct octep_ctrl_net_wait_data d = {0};
237+
struct octep_ctrl_net_wait_data d = {};
220238
struct octep_ctrl_net_h2f_req *req = &d.data.req;
221239
struct octep_ctrl_net_h2f_resp *resp;
222240
int err;
@@ -236,7 +254,7 @@ int octep_ctrl_net_get_if_stats(struct octep_device *oct, int vfid,
236254
int octep_ctrl_net_get_link_info(struct octep_device *oct, int vfid,
237255
struct octep_iface_link_info *link_info)
238256
{
239-
struct octep_ctrl_net_wait_data d = {0};
257+
struct octep_ctrl_net_wait_data d = {};
240258
struct octep_ctrl_net_h2f_req *req = &d.data.req;
241259
struct octep_ctrl_net_h2f_resp *resp;
242260
int err;
@@ -262,7 +280,7 @@ int octep_ctrl_net_set_link_info(struct octep_device *oct, int vfid,
262280
struct octep_iface_link_info *link_info,
263281
bool wait_for_response)
264282
{
265-
struct octep_ctrl_net_wait_data d = {0};
283+
struct octep_ctrl_net_wait_data d = {};
266284
struct octep_ctrl_net_h2f_req *req = &d.data.req;
267285

268286
init_send_req(&d.msg, req, link_info_sz, vfid);
@@ -331,8 +349,8 @@ static int process_mbox_notify(struct octep_device *oct,
331349
void octep_ctrl_net_recv_fw_messages(struct octep_device *oct)
332350
{
333351
static u16 msg_sz = sizeof(union octep_ctrl_net_max_data);
334-
union octep_ctrl_net_max_data data = {0};
335-
struct octep_ctrl_mbox_msg msg = {0};
352+
union octep_ctrl_net_max_data data = {};
353+
struct octep_ctrl_mbox_msg msg = {};
336354
int ret;
337355

338356
msg.hdr.s.sz = msg_sz;
@@ -356,7 +374,7 @@ void octep_ctrl_net_recv_fw_messages(struct octep_device *oct)
356374
int octep_ctrl_net_get_info(struct octep_device *oct, int vfid,
357375
struct octep_fw_info *info)
358376
{
359-
struct octep_ctrl_net_wait_data d = {0};
377+
struct octep_ctrl_net_wait_data d = {};
360378
struct octep_ctrl_net_h2f_resp *resp;
361379
struct octep_ctrl_net_h2f_req *req;
362380
int err;

drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h

Lines changed: 74 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -218,111 +218,131 @@ struct octep_ctrl_net_wait_data {
218218
} data;
219219
};
220220

221-
/** Initialize data for ctrl net.
221+
/**
222+
* octep_ctrl_net_init() - Initialize data for ctrl net.
222223
*
223-
* @param oct: non-null pointer to struct octep_device.
224+
* @oct: non-null pointer to struct octep_device.
224225
*
225226
* return value: 0 on success, -errno on error.
226227
*/
227228
int octep_ctrl_net_init(struct octep_device *oct);
228229

229-
/** Get link status from firmware.
230+
/**
231+
* octep_ctrl_net_get_link_status() - Get link status from firmware.
230232
*
231-
* @param oct: non-null pointer to struct octep_device.
232-
* @param vfid: Index of virtual function.
233+
* @oct: non-null pointer to struct octep_device.
234+
* @vfid: Index of virtual function.
233235
*
234236
* return value: link status 0=down, 1=up.
235237
*/
236238
int octep_ctrl_net_get_link_status(struct octep_device *oct, int vfid);
237239

238-
/** Set link status in firmware.
240+
/**
241+
* octep_ctrl_net_set_link_status() - Set link status in firmware.
239242
*
240-
* @param oct: non-null pointer to struct octep_device.
241-
* @param vfid: Index of virtual function.
242-
* @param up: boolean status.
243-
* @param wait_for_response: poll for response.
243+
* @oct: non-null pointer to struct octep_device.
244+
* @vfid: Index of virtual function.
245+
* @up: boolean status.
246+
* @wait_for_response: poll for response.
244247
*
245248
* return value: 0 on success, -errno on failure
246249
*/
247250
int octep_ctrl_net_set_link_status(struct octep_device *oct, int vfid, bool up,
248251
bool wait_for_response);
249252

250-
/** Set rx state in firmware.
253+
/**
254+
* octep_ctrl_net_set_rx_state() - Set rx state in firmware.
251255
*
252-
* @param oct: non-null pointer to struct octep_device.
253-
* @param vfid: Index of virtual function.
254-
* @param up: boolean status.
255-
* @param wait_for_response: poll for response.
256+
* @oct: non-null pointer to struct octep_device.
257+
* @vfid: Index of virtual function.
258+
* @up: boolean status.
259+
* @wait_for_response: poll for response.
256260
*
257261
* return value: 0 on success, -errno on failure.
258262
*/
259263
int octep_ctrl_net_set_rx_state(struct octep_device *oct, int vfid, bool up,
260264
bool wait_for_response);
261265

262-
/** Get mac address from firmware.
266+
/**
267+
* octep_ctrl_net_get_mac_addr() - Get mac address from firmware.
263268
*
264-
* @param oct: non-null pointer to struct octep_device.
265-
* @param vfid: Index of virtual function.
266-
* @param addr: non-null pointer to mac address.
269+
* @oct: non-null pointer to struct octep_device.
270+
* @vfid: Index of virtual function.
271+
* @addr: non-null pointer to mac address.
267272
*
268273
* return value: 0 on success, -errno on failure.
269274
*/
270275
int octep_ctrl_net_get_mac_addr(struct octep_device *oct, int vfid, u8 *addr);
271276

272-
/** Set mac address in firmware.
277+
/**
278+
* octep_ctrl_net_set_mac_addr() - Set mac address in firmware.
273279
*
274-
* @param oct: non-null pointer to struct octep_device.
275-
* @param vfid: Index of virtual function.
276-
* @param addr: non-null pointer to mac address.
277-
* @param wait_for_response: poll for response.
280+
* @oct: non-null pointer to struct octep_device.
281+
* @vfid: Index of virtual function.
282+
* @addr: non-null pointer to mac address.
283+
* @wait_for_response: poll for response.
278284
*
279285
* return value: 0 on success, -errno on failure.
280286
*/
281287
int octep_ctrl_net_set_mac_addr(struct octep_device *oct, int vfid, u8 *addr,
282288
bool wait_for_response);
283289

284-
/** Set mtu in firmware.
290+
/**
291+
* octep_ctrl_net_get_mtu() - Get max MTU from firmware.
285292
*
286-
* @param oct: non-null pointer to struct octep_device.
287-
* @param vfid: Index of virtual function.
288-
* @param mtu: mtu.
289-
* @param wait_for_response: poll for response.
293+
* @oct: non-null pointer to struct octep_device.
294+
* @vfid: Index of virtual function.
295+
*
296+
* return value: mtu on success, -errno on failure.
297+
*/
298+
int octep_ctrl_net_get_mtu(struct octep_device *oct, int vfid);
299+
300+
/**
301+
* octep_ctrl_net_set_mtu() - Set mtu in firmware.
302+
*
303+
* @oct: non-null pointer to struct octep_device.
304+
* @vfid: Index of virtual function.
305+
* @mtu: mtu.
306+
* @wait_for_response: poll for response.
290307
*
291308
* return value: 0 on success, -errno on failure.
292309
*/
293310
int octep_ctrl_net_set_mtu(struct octep_device *oct, int vfid, int mtu,
294311
bool wait_for_response);
295312

296-
/** Get interface statistics from firmware.
313+
/**
314+
* octep_ctrl_net_get_if_stats() - Get interface statistics from firmware.
297315
*
298-
* @param oct: non-null pointer to struct octep_device.
299-
* @param vfid: Index of virtual function.
300-
* @param rx_stats: non-null pointer struct octep_iface_rx_stats.
301-
* @param tx_stats: non-null pointer struct octep_iface_tx_stats.
316+
* @oct: non-null pointer to struct octep_device.
317+
* @vfid: Index of virtual function.
318+
* @rx_stats: non-null pointer struct octep_iface_rx_stats.
319+
* @tx_stats: non-null pointer struct octep_iface_tx_stats.
302320
*
303321
* return value: 0 on success, -errno on failure.
304322
*/
305323
int octep_ctrl_net_get_if_stats(struct octep_device *oct, int vfid,
306324
struct octep_iface_rx_stats *rx_stats,
307325
struct octep_iface_tx_stats *tx_stats);
308326

309-
/** Get link info from firmware.
327+
/**
328+
* octep_ctrl_net_get_link_info() - Get link info from firmware.
310329
*
311-
* @param oct: non-null pointer to struct octep_device.
312-
* @param vfid: Index of virtual function.
313-
* @param link_info: non-null pointer to struct octep_iface_link_info.
330+
* @oct: non-null pointer to struct octep_device.
331+
* @vfid: Index of virtual function.
332+
* @link_info: non-null pointer to struct octep_iface_link_info.
314333
*
315334
* return value: 0 on success, -errno on failure.
316335
*/
317336
int octep_ctrl_net_get_link_info(struct octep_device *oct, int vfid,
318337
struct octep_iface_link_info *link_info);
319338

320-
/** Set link info in firmware.
339+
/**
340+
* octep_ctrl_net_set_link_info() - Set link info in firmware.
321341
*
322-
* @param oct: non-null pointer to struct octep_device.
323-
* @param vfid: Index of virtual function.
324-
* @param link_info: non-null pointer to struct octep_iface_link_info.
325-
* @param wait_for_response: poll for response.
342+
* @oct: non-null pointer to struct octep_device.
343+
* @vfid: Index of virtual function.
344+
* @link_info: non-null pointer to struct octep_iface_link_info.
345+
* @wait_for_response: poll for response.
326346
*
327347
* return value: 0 on success, -errno on failure.
328348
*/
@@ -331,26 +351,29 @@ int octep_ctrl_net_set_link_info(struct octep_device *oct,
331351
struct octep_iface_link_info *link_info,
332352
bool wait_for_response);
333353

334-
/** Poll for firmware messages and process them.
354+
/**
355+
* octep_ctrl_net_recv_fw_messages() - Poll for firmware messages and process them.
335356
*
336-
* @param oct: non-null pointer to struct octep_device.
357+
* @oct: non-null pointer to struct octep_device.
337358
*/
338359
void octep_ctrl_net_recv_fw_messages(struct octep_device *oct);
339360

340-
/** Get info from firmware.
361+
/**
362+
* octep_ctrl_net_get_info() - Get info from firmware.
341363
*
342-
* @param oct: non-null pointer to struct octep_device.
343-
* @param vfid: Index of virtual function.
344-
* @param info: non-null pointer to struct octep_fw_info.
364+
* @oct: non-null pointer to struct octep_device.
365+
* @vfid: Index of virtual function.
366+
* @info: non-null pointer to struct octep_fw_info.
345367
*
346368
* return value: 0 on success, -errno on failure.
347369
*/
348370
int octep_ctrl_net_get_info(struct octep_device *oct, int vfid,
349371
struct octep_fw_info *info);
350372

351-
/** Uninitialize data for ctrl net.
373+
/**
374+
* octep_ctrl_net_uninit() - Uninitialize data for ctrl net.
352375
*
353-
* @param oct: non-null pointer to struct octep_device.
376+
* @oct: non-null pointer to struct octep_device.
354377
*
355378
* return value: 0 on success, -errno on error.
356379
*/

drivers/net/ethernet/marvell/octeon_ep/octep_main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,7 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
13071307
{
13081308
struct octep_device *octep_dev = NULL;
13091309
struct net_device *netdev;
1310+
int max_rx_pktlen;
13101311
int err;
13111312

13121313
err = pci_enable_device(pdev);
@@ -1377,8 +1378,15 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
13771378

13781379
netdev->hw_features = NETIF_F_SG;
13791380
netdev->features |= netdev->hw_features;
1381+
1382+
max_rx_pktlen = octep_ctrl_net_get_mtu(octep_dev, OCTEP_CTRL_NET_INVALID_VFID);
1383+
if (max_rx_pktlen < 0) {
1384+
dev_err(&octep_dev->pdev->dev,
1385+
"Failed to get max receive packet size; err = %d\n", max_rx_pktlen);
1386+
goto register_dev_err;
1387+
}
13801388
netdev->min_mtu = OCTEP_MIN_MTU;
1381-
netdev->max_mtu = OCTEP_MAX_MTU;
1389+
netdev->max_mtu = max_rx_pktlen - (ETH_HLEN + ETH_FCS_LEN);
13821390
netdev->mtu = OCTEP_DEFAULT_MTU;
13831391

13841392
err = octep_ctrl_net_get_mac_addr(octep_dev, OCTEP_CTRL_NET_INVALID_VFID,

0 commit comments

Comments
 (0)