aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can/flexcan/flexcan-ethtool.c
blob: 50e86b2da53286f5c2173b517897be8185a78d8b (plain) (blame)
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
// SPDX-License-Identifier: GPL-2.0+
/* Copyright (c) 2022 Amarula Solutions, Dario Binacchi <dario.binacchi@amarulasolutions.com>
 * Copyright (c) 2022 Pengutronix, Marc Kleine-Budde <kernel@pengutronix.de>
 *
 */

#include <linux/can/dev.h>
#include <linux/ethtool.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/platform_device.h>

#include "flexcan.h"

static const char flexcan_priv_flags_strings[][ETH_GSTRING_LEN] = {
#define FLEXCAN_PRIV_FLAGS_RX_RTR BIT(0)
	"rx-rtr",
};

static void
flexcan_get_ringparam(struct net_device *ndev, struct ethtool_ringparam *ring,
		      struct kernel_ethtool_ringparam *kernel_ring,
		      struct netlink_ext_ack *ext_ack)
{
	const struct flexcan_priv *priv = netdev_priv(ndev);

	ring->rx_max_pending = priv->mb_count;
	ring->tx_max_pending = priv->mb_count;

	if (priv->devtype_data.quirks & FLEXCAN_QUIRK_USE_RX_MAILBOX)
		ring->rx_pending = priv->offload.mb_last -
			priv->offload.mb_first + 1;
	else
		ring->rx_pending = 6;	/* RX-FIFO depth is fixed */

	/* the drive currently supports only on TX buffer */
	ring->tx_pending = 1;
}

static void
flexcan_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
{
	switch (stringset) {
	case ETH_SS_PRIV_FLAGS:
		memcpy(data, flexcan_priv_flags_strings,
		       sizeof(flexcan_priv_flags_strings));
	}
}

static u32 flexcan_get_priv_flags(struct net_device *ndev)
{
	const struct flexcan_priv *priv = netdev_priv(ndev);
	u32 priv_flags = 0;

	if (flexcan_active_rx_rtr(priv))
		priv_flags |= FLEXCAN_PRIV_FLAGS_RX_RTR;

	return priv_flags;
}

static int flexcan_set_priv_flags(struct net_device *ndev, u32 priv_flags)
{
	struct flexcan_priv *priv = netdev_priv(ndev);
	u32 quirks = priv->devtype_data.quirks;

	if (priv_flags & FLEXCAN_PRIV_FLAGS_RX_RTR) {
		if (flexcan_supports_rx_mailbox_rtr(priv))
			quirks |= FLEXCAN_QUIRK_USE_RX_MAILBOX;
		else if (flexcan_supports_rx_fifo(priv))
			quirks &= ~FLEXCAN_QUIRK_USE_RX_MAILBOX;
		else
			quirks |= FLEXCAN_QUIRK_USE_RX_MAILBOX;
	} else {
		if (flexcan_supports_rx_mailbox(priv))
			quirks |= FLEXCAN_QUIRK_USE_RX_MAILBOX;
		else
			quirks &= ~FLEXCAN_QUIRK_USE_RX_MAILBOX;
	}

	if (quirks != priv->devtype_data.quirks && netif_running(ndev))
		return -EBUSY;

	priv->devtype_data.quirks = quirks;

	if (!(priv_flags & FLEXCAN_PRIV_FLAGS_RX_RTR) &&
	    !flexcan_active_rx_rtr(priv))
		netdev_info(ndev,
			    "Activating RX mailbox mode, cannot receive RTR frames.\n");

	return 0;
}

static int flexcan_get_sset_count(struct net_device *netdev, int sset)
{
	switch (sset) {
	case ETH_SS_PRIV_FLAGS:
		return ARRAY_SIZE(flexcan_priv_flags_strings);
	default:
		return -EOPNOTSUPP;
	}
}

const struct ethtool_ops flexcan_ethtool_ops = {
	.get_ringparam = flexcan_get_ringparam,
	.get_strings = flexcan_get_strings,
	.get_priv_flags = flexcan_get_priv_flags,
	.set_priv_flags = flexcan_set_priv_flags,
	.get_sset_count = flexcan_get_sset_count,
	.get_ts_info = ethtool_op_get_ts_info,
};
ons'>+4 Enable CG and PG flags for VCN on IP 11_5_0 Signed-off-by: Saleemkhan Jamadar <saleemkhan.jamadar@amd.com> Acked-by: Leo Liu <leo.liu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: add VCN_4_0_5 firmware supportSaleemkhan Jamadar1-0/+2 Add VCN_4_0_5 firmware support Signed-off-by: Saleemkhan Jamadar <saleemkhan.jamadar@amd.com> Acked-by: Leo Liu <leo.liu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu/jpeg: add jpeg support for VCN4_0_5Saleemkhan Jamadar3-1/+658 Add jpeg support for VCN4_0_5 v2 - update license year (Leo Liu) Signed-off-by: Saleemkhan Jamadar <saleemkhan.jamadar@amd.com> Acked-by: Leo Liu <leo.liu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: add VCN4 ip block supportSaleemkhan Jamadar3-0/+1815 Add VCN 4.0.5 initialization and decoder/encoder ring functions. v2 - update license year (Leo Liu) Signed-off-by: Saleemkhan Jamadar <saleemkhan.jamadar@amd.com> Acked-by: Leo Liu <leo.liu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: add vcn 4_0_5 header filesSaleemkhan Jamadar2-0/+10411 Add VCN 4.0.5 registers v2 - Add license header (Alexander Deucher) v3 - updates (Alex) Signed-off-by: Saleemkhan Jamadar <saleemkhan.jamadar@amd.com> Acked-by: Leo Liu <leo.liu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: fix VPE front door loading issueLang Yu6-0/+63 Implement proper front door loading for vpe 6.1. Signed-off-by: Lang Yu <Lang.Yu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: add VPE FW version query supportLang Yu2-0/+14 Add support to query VPE FW version. Signed-off-by: Lang Yu <Lang.Yu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: enable VPE for VPE 6.1.0Lang Yu1-0/+19 Enable Video Processing Engine on SoCs that contain VPE 6.1.0. Signed-off-by: Lang Yu <Lang.Yu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: add user space CS support for VPELang Yu3-0/+9 Enable command submission to VPE from user space. Signed-off-by: Lang Yu <Lang.Yu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: add PSP loading support for VPELang Yu2-0/+28 Add PSP loading support for Video Processing Engine. Signed-off-by: Lang Yu <Lang.Yu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: add VPE 6.1.0 supportLang Yu6-0/+1019 Add skeleton driver code. (Ray) Add initial support for Video Processing Engine. (Lang) Signed-off-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Lang Yu <Lang.Yu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: add nbio 7.11 callback for VPELang Yu1-0/+24 Add nbio callback to configure doorbell settings. Signed-off-by: Lang Yu <Lang.Yu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: add nbio callback for VPELang Yu1-0/+2 Add nbio callback to configure doorbell settings. Signed-off-by: Lang Yu <Lang.Yu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: add PSP FW TYPE for VPELang Yu2-0/+8 Add PSP FW TYPE for Video Processing Engine. Signed-off-by: Lang Yu <Lang.Yu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: add UCODE ID for VPELang Yu1-0/+2 Add UCODE ID for Video Processing Engine. Signed-off-by: Lang Yu <Lang.Yu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: add support for VPE firmware name decodingLang Yu1-0/+3 Add decoding VPE firmware name support. Signed-off-by: Lang Yu <Lang.Yu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> 2023-08-31drm/amdgpu: add doorbell index for VPELang Yu2-2/+6 Add doorbell index for Video Processing Engine. Signed-off-by: Lang Yu <Lang.Yu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>