mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-26 00:21:17 +00:00
can: netlink support for bus-error reporting and counters
This patch makes the bus-error reporting configurable and allows to retrieve the CAN TX and RX bus error counters via netlink interface. I have added support for the SJA1000. The TX and RX bus error counters are also copied to the data fields 6..7 of error messages when state changes are reported. Signed-off-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
78ca90ea99
commit
52c793f240
4 changed files with 44 additions and 7 deletions
|
@ -574,6 +574,7 @@ static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = {
|
|||
[IFLA_CAN_BITTIMING_CONST]
|
||||
= { .len = sizeof(struct can_bittiming_const) },
|
||||
[IFLA_CAN_CLOCK] = { .len = sizeof(struct can_clock) },
|
||||
[IFLA_CAN_BERR_COUNTER] = { .len = sizeof(struct can_berr_counter) },
|
||||
};
|
||||
|
||||
static int can_changelink(struct net_device *dev,
|
||||
|
@ -649,6 +650,8 @@ static size_t can_get_size(const struct net_device *dev)
|
|||
size += nla_total_size(sizeof(u32)); /* IFLA_CAN_RESTART_MS */
|
||||
size += sizeof(struct can_bittiming); /* IFLA_CAN_BITTIMING */
|
||||
size += sizeof(struct can_clock); /* IFLA_CAN_CLOCK */
|
||||
if (priv->do_get_berr_counter) /* IFLA_CAN_BERR_COUNTER */
|
||||
size += sizeof(struct can_berr_counter);
|
||||
if (priv->bittiming_const) /* IFLA_CAN_BITTIMING_CONST */
|
||||
size += sizeof(struct can_bittiming_const);
|
||||
|
||||
|
@ -659,6 +662,7 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev)
|
|||
{
|
||||
struct can_priv *priv = netdev_priv(dev);
|
||||
struct can_ctrlmode cm = {.flags = priv->ctrlmode};
|
||||
struct can_berr_counter bec;
|
||||
enum can_state state = priv->state;
|
||||
|
||||
if (priv->do_get_state)
|
||||
|
@ -669,6 +673,8 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev)
|
|||
NLA_PUT(skb, IFLA_CAN_BITTIMING,
|
||||
sizeof(priv->bittiming), &priv->bittiming);
|
||||
NLA_PUT(skb, IFLA_CAN_CLOCK, sizeof(cm), &priv->clock);
|
||||
if (priv->do_get_berr_counter && !priv->do_get_berr_counter(dev, &bec))
|
||||
NLA_PUT(skb, IFLA_CAN_BERR_COUNTER, sizeof(bec), &bec);
|
||||
if (priv->bittiming_const)
|
||||
NLA_PUT(skb, IFLA_CAN_BITTIMING_CONST,
|
||||
sizeof(*priv->bittiming_const), priv->bittiming_const);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue