---
diff --git a/include/linux/can/netlink.h b/include/linux/can/netlink.h
index 9ecbb78..3250de9 100644
--- a/include/linux/can/netlink.h
+++ b/include/linux/can/netlink.h
@@ -70,6 +70,14 @@ enum can_state {
 };
 
 /*
+ * CAN bus error counters
+ */
+struct can_berr_counter {
+       __u16 txerr;
+       __u16 rxerr;
+};
+
+/*
  * CAN controller mode
  */
 struct can_ctrlmode {
@@ -77,9 +85,11 @@ struct can_ctrlmode {
        __u32 flags;
 };
 
-#define CAN_CTRLMODE_LOOPBACK  0x1     /* Loopback mode */
-#define CAN_CTRLMODE_LISTENONLY        0x2     /* Listen-only mode */
-#define CAN_CTRLMODE_3_SAMPLES 0x4     /* Triple sampling mode */
+#define CAN_CTRLMODE_LOOPBACK          0x01    /* Loopback mode */
+#define CAN_CTRLMODE_LISTENONLY                0x02    /* Listen-only mode */
+#define CAN_CTRLMODE_3_SAMPLES         0x04    /* Triple sampling mode */
+#define CAN_CTRLMODE_ONE_SHOT          0x08    /* One-Shot mode */
+#define CAN_CTRLMODE_BERR_REPORTING    0x10    /* Bus-error reporting */
 
 /*
  * CAN device statistics
@@ -105,6 +115,7 @@ enum {
        IFLA_CAN_CTRLMODE,
        IFLA_CAN_RESTART_MS,
        IFLA_CAN_RESTART,
+       IFLA_CAN_BERR_COUNTER,
        __IFLA_CAN_MAX
 };
 
diff --git a/ip/iplink_can.c b/ip/iplink_can.c
index 50221e1..e22faa0 100644
--- a/ip/iplink_can.c
+++ b/ip/iplink_can.c
@@ -30,6 +30,7 @@ static void usage(void)
                "\t[ loopback { on | off } ]\n"
                "\t[ listen-only { on | off } ]\n"
                "\t[ triple-sampling { on | off } ]\n"
+               "\t[ berr-reporting { on | off } ]\n"
                "\n"
                "\t[ restart-ms TIME-MS ]\n"
                "\t[ restart ]\n"
@@ -84,6 +85,7 @@ static void print_ctrlmode(FILE *f, __u32 cm)
        _PF(CAN_CTRLMODE_LOOPBACK, "LOOPBACK");
        _PF(CAN_CTRLMODE_LISTENONLY, "LISTEN-ONLY");
        _PF(CAN_CTRLMODE_3_SAMPLES, "TRIPLE-SAMPLING");
+       _PF(CAN_CTRLMODE_BERR_REPORTING, "BERR-REPORTING");
 #undef _PF
        if (cm)
                fprintf(f, "%x", cm);
@@ -142,6 +144,10 @@ static int can_parse_opt(struct link_util *lu, int argc, 
char **argv,
                        NEXT_ARG();
                        set_ctrlmode("triple-sampling", *argv, &cm,
                                     CAN_CTRLMODE_3_SAMPLES);
+               } else if (matches(*argv, "berr-reporting") == 0) {
+                       NEXT_ARG();
+                       set_ctrlmode("berr-reporting", *argv, &cm,
+                                    CAN_CTRLMODE_BERR_REPORTING);
                } else if (matches(*argv, "restart") == 0) {
                        __u32 val = 1;
 
@@ -200,6 +206,13 @@ static void can_print_opt(struct link_util *lu, FILE *f, 
struct rtattr *tb[])
                        can_state_names[*state] : "UNKNOWN");
        }
 
+       if (tb[IFLA_CAN_BERR_COUNTER]) {
+               struct can_berr_counter *bc =
+                       RTA_DATA(tb[IFLA_CAN_BERR_COUNTER]);
+
+               fprintf(f, "(berr-counter tx %d rx %d) ", bc->txerr, bc->rxerr);
+       }
+
        if (tb[IFLA_CAN_RESTART_MS]) {
                __u32 *restart_ms = RTA_DATA(tb[IFLA_CAN_RESTART_MS]);
 
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

Reply via email to