Commit 748944e5 authored by Federico Vaga's avatar Federico Vaga

sw:fw:ep: dedicated function to build high low MAC

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 22bf789c
...@@ -72,6 +72,21 @@ void pr_message(struct trtl_fw_msg *msg) ...@@ -72,6 +72,21 @@ void pr_message(struct trtl_fw_msg *msg)
pp_printf("%s: data[%d] = 0x%"PRIx32"\n\r", __func__, i , d[i]); pp_printf("%s: data[%d] = 0x%"PRIx32"\n\r", __func__, i , d[i]);
} }
static inline uint32_t ep_eth_build_mac_hi(struct trtl_ep_eth_address* addr)
{
return ((uint32_t)addr->dst_mac[0] << 8 ) |
((uint32_t)addr->dst_mac[1] << 0);
}
static inline uint32_t ep_eth_build_mac_lo(struct trtl_ep_eth_address* addr)
{
return ((uint32_t)addr->dst_mac[2] << 24) |
((uint32_t)addr->dst_mac[3] << 16) |
((uint32_t)addr->dst_mac[4] << 8) |
((uint32_t)addr->dst_mac[5] << 0);
}
static inline void rmq_ep_out_writel(int slot, uint32_t data, uint32_t addr) static inline void rmq_ep_out_writel(int slot, uint32_t data, uint32_t addr)
{ {
mq_writel( TRTL_RMQ, data, addr + TRTL_MQ_SLOT_ENDPOINT_CONFIG_START + TRTL_MQ_SLOT_OUT (slot) ); mq_writel( TRTL_RMQ, data, addr + TRTL_MQ_SLOT_ENDPOINT_CONFIG_START + TRTL_MQ_SLOT_OUT (slot) );
...@@ -82,10 +97,9 @@ static inline void rmq_ep_in_writel(int slot, uint32_t data, uint32_t addr) ...@@ -82,10 +97,9 @@ static inline void rmq_ep_in_writel(int slot, uint32_t data, uint32_t addr)
mq_writel( TRTL_RMQ, data, addr + TRTL_MQ_SLOT_ENDPOINT_CONFIG_START + TRTL_MQ_SLOT_IN (slot) ); mq_writel( TRTL_RMQ, data, addr + TRTL_MQ_SLOT_ENDPOINT_CONFIG_START + TRTL_MQ_SLOT_IN (slot) );
} }
static void rmq_ep_bind_in(int slot, struct static void rmq_ep_bind_in(int slot, struct trtl_ep_eth_address* addr)
trtl_ep_eth_address* addr)
{ {
uint32_t cfg = 0; uint32_t cfg = 0, tmp;
switch(addr->type) switch(addr->type)
{ {
...@@ -101,16 +115,10 @@ static void rmq_ep_bind_in(int slot, struct ...@@ -101,16 +115,10 @@ static void rmq_ep_bind_in(int slot, struct
} }
cfg |= addr->filter; cfg |= addr->filter;
uint32_t tmp;
rmq_ep_in_writel( slot, cfg, TRTL_EP_IN_CONFIG ); rmq_ep_in_writel( slot, cfg, TRTL_EP_IN_CONFIG );
tmp = ( (uint32_t)addr->dst_mac[0] << 8 ) | addr->dst_mac[1]; tmp = ep_eth_build_mac_hi(addr);
rmq_ep_in_writel( slot, tmp, TRTL_EP_IN_DST_MAC_HI ); rmq_ep_in_writel( slot, tmp, TRTL_EP_IN_DST_MAC_HI );
tmp = ( (uint32_t)addr->dst_mac[2] << 24 ) | tmp = ep_eth_build_mac_lo(addr);
( (uint32_t)addr->dst_mac[3] << 16 ) |
( (uint32_t)addr->dst_mac[4] << 8 ) |
( (uint32_t)addr->dst_mac[5] << 0 );
rmq_ep_in_writel( slot, tmp, TRTL_EP_IN_DST_MAC_LO ); rmq_ep_in_writel( slot, tmp, TRTL_EP_IN_DST_MAC_LO );
rmq_ep_in_writel( slot, addr->ethertype, TRTL_EP_IN_ETHERTYPE ); rmq_ep_in_writel( slot, addr->ethertype, TRTL_EP_IN_ETHERTYPE );
rmq_ep_in_writel( slot, addr->dst_ip, TRTL_EP_IN_DST_IP ); rmq_ep_in_writel( slot, addr->dst_ip, TRTL_EP_IN_DST_IP );
...@@ -124,14 +132,9 @@ static void rmq_ep_bind_out(int slot, ...@@ -124,14 +132,9 @@ static void rmq_ep_bind_out(int slot,
rmq_ep_out_writel( slot, addr->type == TRTL_EP_FRAME_UDP ? 1 : 0, TRTL_EP_OUT_CONFIG ); rmq_ep_out_writel( slot, addr->type == TRTL_EP_FRAME_UDP ? 1 : 0, TRTL_EP_OUT_CONFIG );
tmp = ( (uint32_t)addr->dst_mac[0] << 8 ) | addr->dst_mac[1]; tmp = ep_eth_build_mac_hi(addr);
rmq_ep_out_writel( slot, tmp, TRTL_EP_OUT_MAC_HI ); rmq_ep_out_writel( slot, tmp, TRTL_EP_OUT_MAC_HI );
tmp = ep_eth_build_mac_lo(addr);
tmp = ( (uint32_t)addr->dst_mac[2] << 24 ) |
( (uint32_t)addr->dst_mac[3] << 16 ) |
( (uint32_t)addr->dst_mac[4] << 8 ) |
( (uint32_t)addr->dst_mac[5] << 0 );
rmq_ep_out_writel( slot, tmp, TRTL_EP_OUT_MAC_LO ); rmq_ep_out_writel( slot, tmp, TRTL_EP_OUT_MAC_LO );
rmq_ep_out_writel( slot, addr->ethertype, TRTL_EP_OUT_ETHERTYPE ); rmq_ep_out_writel( slot, addr->ethertype, TRTL_EP_OUT_ETHERTYPE );
rmq_ep_out_writel( slot, addr->src_ip, TRTL_EP_OUT_SRC_IP ); rmq_ep_out_writel( slot, addr->src_ip, TRTL_EP_OUT_SRC_IP );
......
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