Commit d2081838 authored by Adam Wujek's avatar Adam Wujek 💬

time-wrs: fix VLAN handling for new kernel in wrs

--Read VLAN number from aux; network driver strips VLAN information from the
  frame
--Remove a hack from common-fun.c fro WRS, it is not needed anymore;
  even for WRS we read VLAN from aux
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent a14ec0c0
...@@ -49,11 +49,7 @@ void pp_prepare_pointers(struct pp_instance *ppi) ...@@ -49,11 +49,7 @@ void pp_prepare_pointers(struct pp_instance *ppi)
break; break;
case PPSI_PROTO_VLAN: case PPSI_PROTO_VLAN:
ppi->tx_offset = sizeof(struct pp_vlanhdr); ppi->tx_offset = sizeof(struct pp_vlanhdr);
/* Hack warning: with wrs we get the whole header */ ppi->rx_offset = ETH_HLEN;
if (ARCH_IS_WRS)
ppi->rx_offset = sizeof(struct pp_vlanhdr);
else
ppi->rx_offset = ETH_HLEN;
break; break;
case PPSI_PROTO_UDP: case PPSI_PROTO_UDP:
ppi->tx_offset = 0; ppi->tx_offset = 0;
......
...@@ -160,7 +160,6 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len, ...@@ -160,7 +160,6 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
TimeInternal *t) TimeInternal *t)
{ {
struct ethhdr *hdr = pkt; struct ethhdr *hdr = pkt;
struct pp_vlanhdr *vhdr = pkt;
struct wrs_socket *s; struct wrs_socket *s;
struct msghdr msg; struct msghdr msg;
struct iovec entry; struct iovec entry;
...@@ -168,7 +167,8 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len, ...@@ -168,7 +167,8 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
int i; int i;
union { union {
struct cmsghdr cm; struct cmsghdr cm;
char control[1024]; char aux_buf[CMSG_SPACE(sizeof(struct tpacket_auxdata))];
char time_buf[1024];
} control; } control;
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
struct scm_timestamping *sts = NULL; struct scm_timestamping *sts = NULL;
...@@ -239,32 +239,19 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len, ...@@ -239,32 +239,19 @@ static int wrs_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
} }
drop: drop:
if (aux) {
pp_diag(ppi, frames, 1,"aux: %x proto %x\n", aux->tp_vlan_tci,
ntohs(hdr->h_proto));
if (0) {
fprintf(stderr,
"PPSi error: unexpected auxiliary data\n");
errno = EINVAL;
return -1;
}
}
/* For UDP, avoid all of the following, as we don't have vlans */ /* For UDP, avoid all of the following, as we don't have vlans */
if (ppi->proto == PPSI_PROTO_UDP) if (ppi->proto == PPSI_PROTO_UDP)
goto out; goto out;
/* /*
* While on PC-class ethernet driver we see the internal frame, * Ethernet driver returns internal frame. Our simple WR driver used to
* our simple WR driver returns the whole frame. No aux pointer * return the whole frame, but not anymore. Use aux pointer to get VLAN
* is there, at this point in time. So unroll vlan header.
*/ */
if (vhdr->h_tpid == htons(0x8100)) { if (aux) {
int vlan = ntohs(vhdr->h_tci) & 0xfff; int vlan = aux->tp_vlan_tci & 0xfff;
/* With PROTO_VLAN, we bound to ETH_P_ALL: we got all frames */ /* With PROTO_VLAN, we bound to ETH_P_ALL: we got all frames */
if (vhdr->h_proto != htons(ETH_P_1588)) if (hdr->h_proto != htons(ETH_P_1588))
return -2; /* like "dropped", so no error message */ return -2; /* like "dropped", so no error message */
/* Also, we got the vlan, and we can discard it if not ours */ /* Also, we got the vlan, and we can discard it if not ours */
...@@ -617,6 +604,7 @@ static int wrs_enable_timestamps(struct pp_instance *ppi, int fd) ...@@ -617,6 +604,7 @@ static int wrs_enable_timestamps(struct pp_instance *ppi, int fd)
strerror(errno)); strerror(errno));
return -1; return -1;
} }
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment