Skip to content

Commit 487e193

Browse files
alexaust-xlnxdavem330
authored andcommitted
sfc: make coding style of PTP addresses consistent with core
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 <[email protected]> Reviewed-by: Edward Cree <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 01b38de commit 487e193

File tree

1 file changed

+14
-13
lines changed
  • drivers/net/ethernet/sfc

1 file changed

+14
-13
lines changed

drivers/net/ethernet/sfc/ptp.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,17 @@
108108
#define PTP_MIN_LENGTH 63
109109

110110
#define PTP_ADDR_IPV4 0xe0000181 /* 224.0.1.129 */
111-
#define PTP_ADDR_IPV6 {0xff, 0x0e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
112-
0, 0x01, 0x81} /* ff0e::181 */
111+
112+
/* ff0e::181 */
113+
static const struct in6_addr ptp_addr_ipv6 = { { {
114+
0xff, 0x0e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01, 0x81 } } };
115+
116+
/* 01-1B-19-00-00-00 */
117+
static const u8 ptp_addr_ether[ETH_ALEN] __aligned(2) = {
118+
0x01, 0x1b, 0x19, 0x00, 0x00, 0x00 };
119+
113120
#define PTP_EVENT_PORT 319
114121
#define PTP_GENERAL_PORT 320
115-
#define PTP_ADDR_ETHER {0x01, 0x1b, 0x19, 0, 0, 0} /* 01-1B-19-00-00-00 */
116122

117123
/* Annoyingly the format of the version numbers are different between
118124
* 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,
12961302

12971303
static int efx_ptp_insert_ipv6_filter(struct efx_nic *efx,
12981304
struct list_head *filter_list,
1299-
struct in6_addr *addr, u16 port,
1305+
const struct in6_addr *addr, u16 port,
13001306
unsigned long expiry)
13011307
{
13021308
struct efx_filter_spec spec;
@@ -1309,11 +1315,10 @@ static int efx_ptp_insert_ipv6_filter(struct efx_nic *efx,
13091315
static int efx_ptp_insert_eth_multicast_filter(struct efx_nic *efx)
13101316
{
13111317
struct efx_ptp_data *ptp = efx->ptp_data;
1312-
const u8 addr[ETH_ALEN] = PTP_ADDR_ETHER;
13131318
struct efx_filter_spec spec;
13141319

13151320
efx_ptp_init_filter(efx, &spec);
1316-
efx_filter_set_eth_local(&spec, EFX_FILTER_VID_UNSPEC, addr);
1321+
efx_filter_set_eth_local(&spec, EFX_FILTER_VID_UNSPEC, ptp_addr_ether);
13171322
spec.match_flags |= EFX_FILTER_MATCH_ETHER_TYPE;
13181323
spec.ether_type = htons(ETH_P_1588);
13191324
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)
13461351
* PTP over IPv6 and Ethernet
13471352
*/
13481353
if (efx_ptp_use_mac_tx_timestamps(efx)) {
1349-
struct in6_addr ipv6_addr = {{PTP_ADDR_IPV6}};
1350-
13511354
rc = efx_ptp_insert_ipv6_filter(efx, &ptp->rxfilters_mcast,
1352-
&ipv6_addr, PTP_EVENT_PORT, 0);
1355+
&ptp_addr_ipv6, PTP_EVENT_PORT, 0);
13531356
if (rc < 0)
13541357
goto fail;
13551358

13561359
rc = efx_ptp_insert_ipv6_filter(efx, &ptp->rxfilters_mcast,
1357-
&ipv6_addr, PTP_GENERAL_PORT, 0);
1360+
&ptp_addr_ipv6, PTP_GENERAL_PORT, 0);
13581361
if (rc < 0)
13591362
goto fail;
13601363

@@ -1379,9 +1382,7 @@ static bool efx_ptp_valid_unicast_event_pkt(struct sk_buff *skb)
13791382
ip_hdr(skb)->protocol == IPPROTO_UDP &&
13801383
udp_hdr(skb)->source == htons(PTP_EVENT_PORT);
13811384
} else if (skb->protocol == htons(ETH_P_IPV6)) {
1382-
struct in6_addr mcast_addr = {{PTP_ADDR_IPV6}};
1383-
1384-
return !ipv6_addr_equal(&ipv6_hdr(skb)->daddr, &mcast_addr) &&
1385+
return !ipv6_addr_equal(&ipv6_hdr(skb)->daddr, &ptp_addr_ipv6) &&
13851386
ipv6_hdr(skb)->nexthdr == IPPROTO_UDP &&
13861387
udp_hdr(skb)->source == htons(PTP_EVENT_PORT);
13871388
}

0 commit comments

Comments
 (0)