~funderscore blog cgit wiki get in touch
aboutsummaryrefslogtreecommitdiff
blob: 37d9a2bb730ce3faabb4bd2b4de3696b0dd1a3c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
// SPDX-License-Identifier:    GPL-2.0
/*
 * Copyright (C) 2018 Marvell International Ltd.
 */

#include <dm.h>
#include <errno.h>
#include <malloc.h>
#include <misc.h>
#include <net.h>

#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/list.h>

#include <asm/arch/board.h>
#include <asm/io.h>

#include "cgx_intf.h"
#include "cgx.h"
#include "nix.h"

static u64 cgx_rd_scrx(u8 cgx, u8 lmac, u8 index)
{
	u64 addr;

	addr = (index == 1) ? CGX_CMR_SCRATCH1 : CGX_CMR_SCRATCH0;
	addr += CGX_SHIFT(cgx) + CMR_SHIFT(lmac);
	return readq(addr);
}

static void cgx_wr_scrx(u8 cgx, u8 lmac, u8 index, u64 val)
{
	u64 addr;

	addr = (index == 1) ? CGX_CMR_SCRATCH1 : CGX_CMR_SCRATCH0;
	addr += CGX_SHIFT(cgx) + CMR_SHIFT(lmac);
	writeq(val, addr);
}

static u64 cgx_rd_scr0(u8 cgx, u8 lmac)
{
	return cgx_rd_scrx(cgx, lmac, 0);
}

static u64 cgx_rd_scr1(u8 cgx, u8 lmac)
{
	return cgx_rd_scrx(cgx, lmac, 1);
}

static void cgx_wr_scr0(u8 cgx, u8 lmac, u64 val)
{
	return cgx_wr_scrx(cgx, lmac, 0, val);
}

static void cgx_wr_scr1(u8 cgx, u8 lmac, u64 val)
{
	return cgx_wr_scrx(cgx, lmac, 1, val);
}

static inline void set_ownership(u8 cgx, u8 lmac, u8 val)
{
	union cgx_scratchx1 scr1;

	scr1.u = cgx_rd_scr1(cgx, lmac);
	scr1.s.own_status = val;
	cgx_wr_scr1(cgx, lmac, scr1.u);
}

static int wait_for_ownership(u8 cgx, u8 lmac)
{
	union cgx_scratchx1 scr1;
	union cgx_scratchx0 scr0;
	u64 cmrx_int;
	int timeout = 5000;

	do {
		scr1.u = cgx_rd_scr1(cgx, lmac);
		scr0.u = cgx_rd_scr0(cgx, lmac);
		/* clear async events if any */
		if (scr0.s.evt_sts.evt_type == CGX_EVT_ASYNC &&
		    scr0.s.evt_sts.ack) {
			/* clear interrupt */
			cmrx_int = readq(CGX_CMR_INT +
					 CGX_SHIFT(cgx) + CMR_SHIFT(lmac));
			cmrx_int |= 0x2; // Overflw bit
			writeq(cmrx_int, CGX_CMR_INT +
					 CGX_SHIFT(cgx) + CMR_SHIFT(lmac));

			/* clear ack */
			scr0.s.evt_sts.ack = 0;
			cgx_wr_scr0(cgx, lmac, scr0.u);
		}

		if (timeout-- < 0) {
			debug("timeout waiting for ownership\n");
			return -ETIMEDOUT;
		}
		mdelay(1);
	} while ((scr1.s.own_status == CGX_OWN_FIRMWARE) &&
		  scr0.s.evt_sts.ack);

	return 0;
}

int cgx_intf_req(u8 cgx, u8 lmac, union cgx_cmd_s cmd_args, u64 *rsp,
		 int use_cmd_id_only)
{
	union cgx_scratchx1 scr1;
	union cgx_scratchx0 scr0;
	u64 cmrx_int;
	int timeout = 500;
	int err = 0;
	u8 cmd = cmd_args.cmd.id;

	if (wait_for_ownership(cgx, lmac)) {
		err = -ETIMEDOUT;
		goto error;
	}

	/* send command */
	scr1.u = cgx_rd_scr1(cgx, lmac);

	if (use_cmd_id_only) {
		scr1.s.cmd.id = cmd;
	} else {
		cmd_args.own_status = scr1.s.own_status;
		scr1.s = cmd_args;
	}
	cgx_wr_scr1(cgx, lmac, scr1.u);

	set_ownership(cgx, lmac, CGX_OWN_FIRMWARE);

	/* wait for response and ownership */
	do {
		scr0.u = cgx_rd_scr0(cgx, lmac);
		scr1.u = cgx_rd_scr1(cgx, lmac);
		mdelay(10);
	} while (timeout-- && (!scr0.s.evt_sts.ack) &&
		 (scr1.s.own_status == CGX_OWN_FIRMWARE));
	if (timeout < 0) {
		debug("%s timeout waiting for ack\n", __func__);
		err = -ETIMEDOUT;
		goto error;
	}

	if (cmd == CGX_CMD_INTF_SHUTDOWN)
		goto error;

	if (scr0.s.evt_sts.evt_type != CGX_EVT_CMD_RESP) {
		debug("%s received async event instead of cmd resp event\n",
		      __func__);
		err = -1;
		goto error;
	}
	if (scr0.s.evt_sts.id != cmd) {
		debug("%s received resp for cmd %d expected cmd %d\n",
		      __func__, scr0.s.evt_sts.id, cmd);
		err = -1;
		goto error;
	}
	if (scr0.s.evt_sts.stat != CGX_STAT_SUCCESS) {
		debug("%s cmd%d failed on cgx%u lmac%u with errcode %d\n",
		      __func__, cmd, cgx, lmac, scr0.s.link_sts.err_type);
		err = -1;
	}

error:
	/* clear interrupt */
	cmrx_int = readq(CGX_CMR_INT + CGX_SHIFT(cgx) + CMR_SHIFT(lmac));
	cmrx_int |= 0x2; // Overflw bit
	writeq(cmrx_int, CGX_CMR_INT + CGX_SHIFT(cgx) + CMR_SHIFT(lmac));

	/* clear ownership and ack */
	scr0.s.evt_sts.ack = 0;
	cgx_wr_scr0(cgx, lmac, scr0.u);

	*rsp = err ? 0 : scr0.u;

	return err;
}

int cgx_intf_get_mac_addr(u8 cgx, u8 lmac, u8 *mac)
{
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_GET_MAC_ADDR;

	ret = cgx_intf_req(cgx, lmac, cmd, &scr0.u, 1);
	if (ret)
		return -1;

	scr0.u >>= 9;
	memcpy(mac, &scr0.u, 6);

	return 0;
}

int cgx_intf_get_ver(u8 cgx, u8 lmac, u8 *ver)
{
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_GET_FW_VER;

	ret = cgx_intf_req(cgx, lmac, cmd, &scr0.u, 1);
	if (ret)
		return -1;

	scr0.u >>= 9;
	*ver = scr0.u & 0xFFFF;

	return 0;
}

int cgx_intf_get_link_sts(u8 cgx, u8 lmac, u64 *lnk_sts)
{
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_GET_LINK_STS;

	ret = cgx_intf_req(cgx, lmac, cmd, &scr0.u, 1);
	if (ret)
		return -1;

	scr0.u >>= 9;
	/* pass the same format as cgx_lnk_sts_s
	 * err_type:10, speed:4, full_duplex:1, link_up:1
	 */
	*lnk_sts = scr0.u & 0xFFFF;
	return 0;
}

int cgx_intf_link_up_dwn(u8 cgx, u8 lmac, u8 up_dwn, u64 *lnk_sts)
{
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = up_dwn ? CGX_CMD_LINK_BRING_UP : CGX_CMD_LINK_BRING_DOWN;

	ret = cgx_intf_req(cgx, lmac, cmd, &scr0.u, 1);
	if (ret)
		return -1;

	scr0.u >>= 9;
	/* pass the same format as cgx_lnk_sts_s
	 * err_type:10, speed:4, full_duplex:1, link_up:1
	 */
	*lnk_sts = scr0.u & 0xFFFF;
	return 0;
}

void cgx_intf_shutdown(void)
{
	union cgx_scratchx0 scr0;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_INTF_SHUTDOWN;

	cgx_intf_req(0, 0, cmd, &scr0.u, 1);
}

int cgx_intf_prbs(u8 qlm, u8 mode, u32 time, u8 lane)
{
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_PRBS;

	cmd.prbs_args.qlm = qlm;
	cmd.prbs_args.mode = mode;
	cmd.prbs_args.time = time;
	cmd.prbs_args.lane = lane;

	ret = cgx_intf_req(0, 0, cmd, &scr0.u, 0);
	if (ret)
		return -1;

	return 0;
}

enum cgx_mode {
	MODE_10G_C2C,
	MODE_10G_C2M,
	MODE_10G_KR,
	MODE_25G_C2C,
	MODE_25G_2_C2C,
	MODE_50G_C2C,
	MODE_50G_4_C2C
};

static char intf_speed_to_str[][8] = {
	"10M",
	"100M",
	"1G",
	"2.5G",
	"5G",
	"10G",
	"20G",
	"25G",
	"40G",
	"50G",
	"80G",
	"100G",
};

static void mode_to_args(int mode, struct cgx_mode_change_args *args)
{
	args->an = 0;
	args->duplex = 0;
	args->port = 0;

	switch (mode) {
	case MODE_10G_C2C:
		args->speed = CGX_LINK_10G;
		args->mode = BIT_ULL(CGX_MODE_10G_C2C_BIT);
		break;
	case MODE_10G_C2M:
		args->speed = CGX_LINK_10G;
		args->mode = BIT_ULL(CGX_MODE_10G_C2M_BIT);
		break;
	case MODE_10G_KR:
		args->speed = CGX_LINK_10G;
		args->mode = BIT_ULL(CGX_MODE_10G_KR_BIT);
		args->an = 1;
		break;
	case MODE_25G_C2C:
		args->speed = CGX_LINK_25G;
		args->mode = BIT_ULL(CGX_MODE_25G_C2C_BIT);
		break;
	case MODE_25G_2_C2C:
		args->speed = CGX_LINK_25G;
		args->mode = BIT_ULL(CGX_MODE_25G_2_C2C_BIT);
		break;
	case MODE_50G_C2C:
		args->speed = CGX_LINK_50G;
		args->mode = BIT_ULL(CGX_MODE_50G_C2C_BIT);
		break;
	case MODE_50G_4_C2C:
		args->speed = CGX_LINK_50G;
		args->mode = BIT_ULL(CGX_MODE_50G_4_C2C_BIT);
	}
}

int cgx_intf_set_mode(struct udevice *ethdev, int mode)
{
	struct rvu_pf *rvu = dev_get_priv(ethdev);
	struct nix *nix = rvu->nix;
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_MODE_CHANGE;

	mode_to_args(mode, &cmd.mode_change_args);

	ret = cgx_intf_req(nix->lmac->cgx->cgx_id, nix->lmac->lmac_id,
			   cmd, &scr0.u, 0);
	if (ret) {
		printf("Mode change command failed for %s\n", ethdev->name);
		return -1;
	}

	cmd.cmd.id = CGX_CMD_GET_LINK_STS;
	ret = cgx_intf_req(nix->lmac->cgx->cgx_id, nix->lmac->lmac_id,
			   cmd, &scr0.u, 1);
	if (ret) {
		printf("Get Link Status failed for %s\n", ethdev->name);
		return -1;
	}

	printf("Current Link Status: ");
	if (scr0.s.link_sts.speed) {
		printf("%s\n", intf_speed_to_str[scr0.s.link_sts.speed]);
		switch (scr0.s.link_sts.fec) {
		case 0:
			printf("FEC_NONE\n");
			break;
		case 1:
			printf("FEC_BASE_R\n");
			break;
		case 2:
			printf("FEC_RS\n");
			break;
		}
		printf("Auto Negotiation %sabled\n",
		       scr0.s.link_sts.an ? "En" : "Dis");
		printf("%s Duplex\n",
		       scr0.s.link_sts.full_duplex ? "Full" : "Half");
	} else {
		printf("Down\n");
	}
	return 0;
}

int cgx_intf_get_mode(struct udevice *ethdev)
{
	struct rvu_pf *rvu = dev_get_priv(ethdev);
	struct nix *nix = rvu->nix;
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_GET_LINK_STS;
	ret = cgx_intf_req(nix->lmac->cgx->cgx_id, nix->lmac->lmac_id,
			   cmd, &scr0.u, 1);
	if (ret) {
		printf("Get link status failed for %s\n", ethdev->name);
		return -1;
	}
	printf("Current Interface Mode: ");
	switch (scr0.s.link_sts.mode) {
	case CGX_MODE_10G_C2C_BIT:
		printf("10G_C2C\n");
		break;
	case CGX_MODE_10G_C2M_BIT:
		printf("10G_C2M\n");
		break;
	case CGX_MODE_10G_KR_BIT:
		printf("10G_KR\n");
		break;
	case CGX_MODE_25G_C2C_BIT:
		printf("25G_C2C\n");
		break;
	case CGX_MODE_25G_2_C2C_BIT:
		printf("25G_2_C2C\n");
		break;
	case CGX_MODE_50G_C2C_BIT:
		printf("50G_C2C\n");
		break;
	case CGX_MODE_50G_4_C2C_BIT:
		printf("50G_4_C2C\n");
		break;
	default:
		printf("Unknown\n");
		break;
	}
	return 0;
}

int cgx_intf_get_fec(struct udevice *ethdev)
{
	struct rvu_pf *rvu = dev_get_priv(ethdev);
	struct nix *nix = rvu->nix;
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_GET_SUPPORTED_FEC;

	ret = cgx_intf_req(nix->lmac->cgx->cgx_id, nix->lmac->lmac_id,
			   cmd, &scr0.u, 1);
	if (ret) {
		printf("Get supported FEC failed for %s\n", ethdev->name);
		return -1;
	}

	printf("Supported FEC type: ");
	switch (scr0.s.supported_fec.fec) {
	case 0:
		printf("FEC_NONE\n");
		break;
	case 1:
		printf("FEC_BASE_R\n");
		break;
	case 2:
		printf("FEC_RS\n");
		break;
	case 3:
		printf("FEC_BASE_R FEC_RS\n");
		break;
	}

	cmd.cmd.id = CGX_CMD_GET_LINK_STS;
	ret = cgx_intf_req(nix->lmac->cgx->cgx_id, nix->lmac->lmac_id,
			   cmd, &scr0.u, 1);
	if (ret) {
		printf("Get active fec failed for %s\n", ethdev->name);
		return -1;
	}
	printf("Active FEC type: ");
	switch (scr0.s.link_sts.fec) {
	case 0:
		printf("FEC_NONE\n");
		break;
	case 1:
		printf("FEC_BASE_R\n");
		break;
	case 2:
		printf("FEC_RS\n");
		break;
	}
	return 0;
}

int cgx_intf_set_fec(struct udevice *ethdev, int type)
{
	struct rvu_pf *rvu = dev_get_priv(ethdev);
	struct nix *nix = rvu->nix;
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_SET_FEC;
	cmd.fec_args.fec = type;

	ret = cgx_intf_req(nix->lmac->cgx->cgx_id, nix->lmac->lmac_id,
			   cmd, &scr0.u, 0);
	if (ret) {
		printf("Set FEC type %d failed for %s\n", type, ethdev->name);
		return -1;
	}
	return 0;
}

int cgx_intf_get_phy_mod_type(struct udevice *ethdev)
{
	struct rvu_pf *rvu = dev_get_priv(ethdev);
	struct nix *nix = rvu->nix;
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_GET_PHY_MOD_TYPE;

	ret = cgx_intf_req(nix->lmac->cgx->cgx_id, nix->lmac->lmac_id,
			   cmd, &scr0.u, 1);
	if (ret) {
		printf("Get PHYMOD type failed for %s\n", ethdev->name);
		return -1;
	}
	printf("Current phy mod type %s\n",
	       scr0.s.phy_mod_type.mod ? "PAM4" : "NRZ");
	return 0;
}

int cgx_intf_set_phy_mod_type(struct udevice *ethdev, int type)
{
	struct rvu_pf *rvu = dev_get_priv(ethdev);
	struct nix *nix = rvu->nix;
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_SET_PHY_MOD_TYPE;
	cmd.phy_mod_args.mod = type;

	ret = cgx_intf_req(nix->lmac->cgx->cgx_id, nix->lmac->lmac_id,
			   cmd, &scr0.u, 0);
	if (ret) {
		printf("Set PHYMOD type %d failed for %s\n", type,
		       ethdev->name);
		return -1;
	}

	return 0;
}

int cgx_intf_set_an_lbk(struct udevice *ethdev, int enable)
{
	struct rvu_pf *rvu = dev_get_priv(ethdev);
	struct nix *nix = rvu->nix;
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_AN_LOOPBACK;
	cmd.cmd_args.enable = enable;

	ret = cgx_intf_req(nix->lmac->cgx->cgx_id, nix->lmac->lmac_id,
			   cmd, &scr0.u, 0);
	if (ret) {
		printf("Set AN loopback command failed on %s\n", ethdev->name);
		return -1;
	}
	printf("AN loopback %s for %s\n", enable ? "set" : "clear",
	       ethdev->name);

	return 0;
}

int cgx_intf_get_ignore(struct udevice *ethdev, int cgx, int lmac)
{
	struct rvu_pf *rvu;
	struct nix *nix;
	union cgx_scratchx0 scr0;
	int ret, cgx_id = cgx, lmac_id = lmac;
	union cgx_cmd_s cmd;

	if (ethdev) {
		rvu = dev_get_priv(ethdev);
		nix = rvu->nix;
		cgx_id = nix->lmac->cgx->cgx_id;
		lmac_id = nix->lmac->lmac_id;
	}
	cmd.cmd.id = CGX_CMD_GET_PERSIST_IGNORE;

	ret = cgx_intf_req(cgx_id, lmac_id, cmd, &scr0.u, 1);
	if (ret) {
		if (ethdev)
			printf("Get ignore command failed for %s\n",
			       ethdev->name);
		else
			printf("Get ignore command failed for CGX%d LMAC%d\n",
			       cgx_id, lmac_id);
		return -1;
	}
	if (ethdev)
		printf("Persist settings %signored for %s\n",
		       scr0.s.persist.ignore ? "" : "not ", ethdev->name);
	else
		printf("Persist settings %signored for CGX%d LMAC%d\n",
		       scr0.s.persist.ignore ? "" : "not ", cgx_id, lmac_id);

	return 0;
}

int cgx_intf_set_ignore(struct udevice *ethdev, int cgx, int lmac, int ignore)
{
	struct rvu_pf *rvu;
	struct nix *nix;
	union cgx_scratchx0 scr0;
	int ret, cgx_id = cgx, lmac_id = lmac;
	union cgx_cmd_s cmd;

	if (ethdev) {
		rvu = dev_get_priv(ethdev);
		nix = rvu->nix;
		cgx_id = nix->lmac->cgx->cgx_id;
		lmac_id = nix->lmac->lmac_id;
	}
	cmd.cmd.id = CGX_CMD_SET_PERSIST_IGNORE;
	cmd.persist_args.ignore = ignore;

	ret = cgx_intf_req(cgx_id, lmac_id, cmd, &scr0.u, 0);
	if (ret) {
		if (ethdev)
			printf("Set ignore command failed for %s\n",
			       ethdev->name);
		else
			printf("Set ignore command failed for CGX%d LMAC%d\n",
			       cgx_id, lmac_id);
		return -1;
	}

	return 0;
}

int cgx_intf_set_macaddr(struct udevice *ethdev)
{
	struct rvu_pf *rvu = dev_get_priv(ethdev);
	struct nix *nix = rvu->nix;
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;
	u64 mac, tmp;

	memcpy((void *)&tmp, nix->lmac->mac_addr, 6);
	mac = swab64(tmp) >> 16;
	cmd.cmd.id = CGX_CMD_SET_MAC_ADDR;
	cmd.mac_args.addr = mac;
	cmd.mac_args.pf_id = rvu->pfid;

	ret = cgx_intf_req(nix->lmac->cgx->cgx_id, nix->lmac->lmac_id,
			   cmd, &scr0.u, 0);
	if (ret) {
		printf("Set user mac addr failed for %s\n", ethdev->name);
		return -1;
	}

	return 0;
}

int cgx_intf_display_eye(u8 qlm, u8 lane)
{
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_DISPLAY_EYE;

	cmd.dsp_eye_args.qlm = qlm;
	cmd.dsp_eye_args.lane = lane;

	ret = cgx_intf_req(0, 0, cmd, &scr0.u, 0);
	if (ret)
		return -1;

	return 0;
}

int cgx_intf_display_serdes(u8 qlm, u8 lane)
{
	union cgx_scratchx0 scr0;
	int ret;
	union cgx_cmd_s cmd;

	cmd.cmd.id = CGX_CMD_DISPLAY_SERDES;

	cmd.dsp_eye_args.qlm = qlm;
	cmd.dsp_eye_args.lane = lane;

	ret = cgx_intf_req(0, 0, cmd, &scr0.u, 0);
	if (ret)
		return -1;

	return 0;
}