transport: pass struct interface to transport_open
Pass struct interface so we can use ts_iface in HW filter. Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>master
parent
536a71031d
commit
8923bcdf64
|
@ -67,6 +67,7 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type,
|
|||
int zero_datalen)
|
||||
{
|
||||
struct pmc *pmc;
|
||||
struct interface iface;
|
||||
|
||||
pmc = calloc(1, sizeof *pmc);
|
||||
if (!pmc)
|
||||
|
@ -90,7 +91,9 @@ struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type,
|
|||
pr_err("failed to create transport");
|
||||
goto failed;
|
||||
}
|
||||
if (transport_open(pmc->transport, iface_name,
|
||||
|
||||
strncpy(iface.name, iface_name, MAX_IFNAME_SIZE);
|
||||
if (transport_open(pmc->transport, &iface,
|
||||
&pmc->fdarray, TS_SOFTWARE)) {
|
||||
pr_err("failed to open transport");
|
||||
goto failed;
|
||||
|
|
4
port.c
4
port.c
|
@ -1504,7 +1504,7 @@ static int port_initialize(struct port *p)
|
|||
goto no_timers;
|
||||
}
|
||||
}
|
||||
if (transport_open(p->trp, p->name, &p->fda, p->timestamping))
|
||||
if (transport_open(p->trp, p->iface, &p->fda, p->timestamping))
|
||||
goto no_tropen;
|
||||
|
||||
for (i = 0; i < N_TIMER_FDS; i++) {
|
||||
|
@ -1547,7 +1547,7 @@ static int port_renew_transport(struct port *p)
|
|||
}
|
||||
transport_close(p->trp, &p->fda);
|
||||
port_clear_fda(p, FD_ANNOUNCE_TIMER);
|
||||
res = transport_open(p->trp, p->name, &p->fda, p->timestamping);
|
||||
res = transport_open(p->trp, p->iface, &p->fda, p->timestamping);
|
||||
/* Need to call clock_fda_changed even if transport_open failed in
|
||||
* order to update clock to the now closed descriptors. */
|
||||
clock_fda_changed(p->clock);
|
||||
|
|
5
raw.c
5
raw.c
|
@ -198,15 +198,16 @@ static void addr_to_mac(void *mac, struct address *addr)
|
|||
memcpy(mac, &addr->sll.sll_addr, MAC_LEN);
|
||||
}
|
||||
|
||||
static int raw_open(struct transport *t, const char *name,
|
||||
static int raw_open(struct transport *t, struct interface *iface,
|
||||
struct fdarray *fda, enum timestamp_type ts_type)
|
||||
{
|
||||
struct raw *raw = container_of(t, struct raw, t);
|
||||
unsigned char ptp_dst_mac[MAC_LEN];
|
||||
unsigned char p2p_dst_mac[MAC_LEN];
|
||||
int efd, gfd;
|
||||
char *str;
|
||||
char *str, *name;
|
||||
|
||||
name = iface->ts_label;
|
||||
str = config_get_string(t->cfg, name, "ptp_dst_mac");
|
||||
if (str2mac(str, ptp_dst_mac)) {
|
||||
pr_err("invalid ptp_dst_mac %s", str);
|
||||
|
|
|
@ -31,10 +31,10 @@ int transport_close(struct transport *t, struct fdarray *fda)
|
|||
return t->close(t, fda);
|
||||
}
|
||||
|
||||
int transport_open(struct transport *t, const char *name,
|
||||
int transport_open(struct transport *t, struct interface *iface,
|
||||
struct fdarray *fda, enum timestamp_type tt)
|
||||
{
|
||||
return t->open(t, name, fda, tt);
|
||||
return t->open(t, iface, fda, tt);
|
||||
}
|
||||
|
||||
int transport_recv(struct transport *t, int fd, struct ptp_message *msg)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "msg.h"
|
||||
|
||||
struct config;
|
||||
struct interface;
|
||||
|
||||
/* Values from networkProtocol enumeration 7.4.1 Table 3 */
|
||||
enum transport_type {
|
||||
|
@ -54,7 +55,7 @@ struct transport;
|
|||
|
||||
int transport_close(struct transport *t, struct fdarray *fda);
|
||||
|
||||
int transport_open(struct transport *t, const char *name,
|
||||
int transport_open(struct transport *t, struct interface *iface,
|
||||
struct fdarray *fda, enum timestamp_type tt);
|
||||
|
||||
int transport_recv(struct transport *t, int fd, struct ptp_message *msg);
|
||||
|
|
|
@ -32,8 +32,8 @@ struct transport {
|
|||
|
||||
int (*close)(struct transport *t, struct fdarray *fda);
|
||||
|
||||
int (*open)(struct transport *t, const char *name, struct fdarray *fda,
|
||||
enum timestamp_type tt);
|
||||
int (*open)(struct transport *t, struct interface *iface,
|
||||
struct fdarray *fda, enum timestamp_type tt);
|
||||
|
||||
int (*recv)(struct transport *t, int fd, void *buf, int buflen,
|
||||
struct address *addr, struct hw_timestamp *hwts);
|
||||
|
|
7
udp.c
7
udp.c
|
@ -152,12 +152,13 @@ enum { MC_PRIMARY, MC_PDELAY };
|
|||
|
||||
static struct in_addr mcast_addr[2];
|
||||
|
||||
static int udp_open(struct transport *t, const char *name, struct fdarray *fda,
|
||||
enum timestamp_type ts_type)
|
||||
static int udp_open(struct transport *t, struct interface *iface,
|
||||
struct fdarray *fda, enum timestamp_type ts_type)
|
||||
{
|
||||
struct udp *udp = container_of(t, struct udp, t);
|
||||
uint8_t event_dscp, general_dscp;
|
||||
int efd, gfd, ttl;
|
||||
char *name = iface->name;
|
||||
|
||||
ttl = config_get_int(t->cfg, name, "udp_ttl");
|
||||
udp->mac.len = 0;
|
||||
|
@ -180,7 +181,7 @@ static int udp_open(struct transport *t, const char *name, struct fdarray *fda,
|
|||
if (gfd < 0)
|
||||
goto no_general;
|
||||
|
||||
if (sk_timestamping_init(efd, name, ts_type, TRANS_UDP_IPV4))
|
||||
if (sk_timestamping_init(efd, iface->ts_label, ts_type, TRANS_UDP_IPV4))
|
||||
goto no_timestamping;
|
||||
|
||||
if (sk_general_init(gfd))
|
||||
|
|
7
udp6.c
7
udp6.c
|
@ -160,12 +160,13 @@ enum { MC_PRIMARY, MC_PDELAY };
|
|||
|
||||
static struct in6_addr mc6_addr[2];
|
||||
|
||||
static int udp6_open(struct transport *t, const char *name, struct fdarray *fda,
|
||||
enum timestamp_type ts_type)
|
||||
static int udp6_open(struct transport *t, struct interface *iface,
|
||||
struct fdarray *fda, enum timestamp_type ts_type)
|
||||
{
|
||||
struct udp6 *udp6 = container_of(t, struct udp6, t);
|
||||
uint8_t event_dscp, general_dscp;
|
||||
int efd, gfd, hop_limit;
|
||||
char *name = iface->name;
|
||||
|
||||
hop_limit = config_get_int(t->cfg, name, "udp_ttl");
|
||||
udp6->mac.len = 0;
|
||||
|
@ -190,7 +191,7 @@ static int udp6_open(struct transport *t, const char *name, struct fdarray *fda,
|
|||
if (gfd < 0)
|
||||
goto no_general;
|
||||
|
||||
if (sk_timestamping_init(efd, name, ts_type, TRANS_UDP_IPV6))
|
||||
if (sk_timestamping_init(efd, iface->ts_label, ts_type, TRANS_UDP_IPV6))
|
||||
goto no_timestamping;
|
||||
|
||||
if (sk_general_init(gfd))
|
||||
|
|
3
uds.c
3
uds.c
|
@ -52,13 +52,14 @@ static int uds_close(struct transport *t, struct fdarray *fda)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int uds_open(struct transport *t, const char *name, struct fdarray *fda,
|
||||
static int uds_open(struct transport *t, struct interface *iface, struct fdarray *fda,
|
||||
enum timestamp_type tt)
|
||||
{
|
||||
int fd, err;
|
||||
struct sockaddr_un sa;
|
||||
struct uds *uds = container_of(t, struct uds, t);
|
||||
char *uds_path = config_get_string(t->cfg, NULL, "uds_address");
|
||||
char *name = iface->name;
|
||||
|
||||
fd = socket(AF_LOCAL, SOCK_DGRAM, 0);
|
||||
if (fd < 0) {
|
||||
|
|
Loading…
Reference in New Issue