]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sfc: make coding style of PTP addresses consistent with core
authorAlex Austin <alex.austin@amd.com>
Thu, 14 Sep 2023 15:19:16 +0000 (16:19 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 16 Sep 2023 10:38:36 +0000 (11:38 +0100)
Follow the style used in the core kernel (e.g.
include/linux/etherdevice.h and include/linux/in6.h) for the PTP IPv6
and Ethernet addresses. No functional changes.

Signed-off-by: Alex Austin <alex.austin@amd.com>
Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/sfc/ptp.c

index f54200f03e15efd4c3d6c7e8cc9b9290fbedb5aa..b04fdbb8aece4850c1260aa2c0e52ddf858fddaa 100644 (file)
 #define        PTP_MIN_LENGTH          63
 
 #define PTP_ADDR_IPV4          0xe0000181      /* 224.0.1.129 */
-#define PTP_ADDR_IPV6          {0xff, 0x0e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
-                               0, 0x01, 0x81}  /* ff0e::181 */
+
+/* ff0e::181 */
+static const struct in6_addr ptp_addr_ipv6 = { { {
+       0xff, 0x0e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01, 0x81 } } };
+
+/* 01-1B-19-00-00-00 */
+static const u8 ptp_addr_ether[ETH_ALEN] __aligned(2) = {
+       0x01, 0x1b, 0x19, 0x00, 0x00, 0x00 };
+
 #define PTP_EVENT_PORT         319
 #define PTP_GENERAL_PORT       320
-#define PTP_ADDR_ETHER         {0x01, 0x1b, 0x19, 0, 0, 0} /* 01-1B-19-00-00-00 */
 
 /* Annoyingly the format of the version numbers are different between
  * versions 1 and 2 so it isn't possible to simply look for 1 or 2.
@@ -1296,7 +1302,7 @@ static int efx_ptp_insert_ipv4_filter(struct efx_nic *efx,
 
 static int efx_ptp_insert_ipv6_filter(struct efx_nic *efx,
                                      struct list_head *filter_list,
-                                     struct in6_addr *addr, u16 port,
+                                     const struct in6_addr *addr, u16 port,
                                      unsigned long expiry)
 {
        struct efx_filter_spec spec;
@@ -1309,11 +1315,10 @@ static int efx_ptp_insert_ipv6_filter(struct efx_nic *efx,
 static int efx_ptp_insert_eth_multicast_filter(struct efx_nic *efx)
 {
        struct efx_ptp_data *ptp = efx->ptp_data;
-       const u8 addr[ETH_ALEN] = PTP_ADDR_ETHER;
        struct efx_filter_spec spec;
 
        efx_ptp_init_filter(efx, &spec);
-       efx_filter_set_eth_local(&spec, EFX_FILTER_VID_UNSPEC, addr);
+       efx_filter_set_eth_local(&spec, EFX_FILTER_VID_UNSPEC, ptp_addr_ether);
        spec.match_flags |= EFX_FILTER_MATCH_ETHER_TYPE;
        spec.ether_type = htons(ETH_P_1588);
        return efx_ptp_insert_filter(efx, &ptp->rxfilters_mcast, &spec, 0);
@@ -1346,15 +1351,13 @@ static int efx_ptp_insert_multicast_filters(struct efx_nic *efx)
         * PTP over IPv6 and Ethernet
         */
        if (efx_ptp_use_mac_tx_timestamps(efx)) {
-               struct in6_addr ipv6_addr = {{PTP_ADDR_IPV6}};
-
                rc = efx_ptp_insert_ipv6_filter(efx, &ptp->rxfilters_mcast,
-                                               &ipv6_addr, PTP_EVENT_PORT, 0);
+                                               &ptp_addr_ipv6, PTP_EVENT_PORT, 0);
                if (rc < 0)
                        goto fail;
 
                rc = efx_ptp_insert_ipv6_filter(efx, &ptp->rxfilters_mcast,
-                                               &ipv6_addr, PTP_GENERAL_PORT, 0);
+                                               &ptp_addr_ipv6, PTP_GENERAL_PORT, 0);
                if (rc < 0)
                        goto fail;
 
@@ -1379,9 +1382,7 @@ static bool efx_ptp_valid_unicast_event_pkt(struct sk_buff *skb)
                        ip_hdr(skb)->protocol == IPPROTO_UDP &&
                        udp_hdr(skb)->source == htons(PTP_EVENT_PORT);
        } else if (skb->protocol == htons(ETH_P_IPV6)) {
-               struct in6_addr mcast_addr = {{PTP_ADDR_IPV6}};
-
-               return !ipv6_addr_equal(&ipv6_hdr(skb)->daddr, &mcast_addr) &&
+               return !ipv6_addr_equal(&ipv6_hdr(skb)->daddr, &ptp_addr_ipv6) &&
                        ipv6_hdr(skb)->nexthdr == IPPROTO_UDP &&
                        udp_hdr(skb)->source == htons(PTP_EVENT_PORT);
        }