Commit 27e6198c authored by Federico Vaga's avatar Federico Vaga

sw:fw:ep style improvement

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent c6aa871a
......@@ -72,84 +72,82 @@ void pr_message(struct trtl_fw_msg *msg)
pp_printf("%s: data[%d] = 0x%"PRIx32"\n\r", __func__, i , d[i]);
}
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) );
}
static inline void rmq_ep_in_writel( int slot, uint32_t data, uint32_t addr )
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 trtl_ep_address* addr )
static void rmq_ep_bind_in(int slot, struct trtl_ep_eth_address* addr)
{
uint32_t cfg = 0;
switch(addr->type)
{
case TRTL_EP_FRAME_UDP:
cfg |= TRTL_EP_FILTER_UDP;
break;
case TRTL_EP_FRAME_TLV:
cfg |= TRTL_EP_FILTER_UDP;
break;
case TRTL_EP_FRAME_RAW:
cfg |= TRTL_EP_FILTER_RAW;
break;
}
cfg |= addr->filter;
uint32_t tmp;
rmq_ep_in_writel( slot, cfg, TRTL_EP_IN_CONFIG );
tmp = ( (uint32_t)addr->dst_mac[0] << 8 ) | addr->dst_mac[1];
rmq_ep_in_writel( slot, tmp, TRTL_EP_IN_DST_MAC_HI );
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_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->dst_ip, TRTL_EP_IN_DST_IP );
rmq_ep_in_writel( slot, addr->dst_port, TRTL_EP_IN_DST_PORT );
uint32_t cfg = 0;
switch(addr->type)
{
case TRTL_EP_FRAME_UDP:
cfg |= TRTL_EP_FILTER_UDP;
break;
case TRTL_EP_FRAME_TLV:
cfg |= TRTL_EP_FILTER_UDP;
break;
case TRTL_EP_FRAME_RAW:
cfg |= TRTL_EP_FILTER_RAW;
break;
}
cfg |= addr->filter;
uint32_t tmp;
rmq_ep_in_writel( slot, cfg, TRTL_EP_IN_CONFIG );
tmp = ( (uint32_t)addr->dst_mac[0] << 8 ) | addr->dst_mac[1];
rmq_ep_in_writel( slot, tmp, TRTL_EP_IN_DST_MAC_HI );
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_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->dst_ip, TRTL_EP_IN_DST_IP );
rmq_ep_in_writel( slot, addr->dst_port, TRTL_EP_IN_DST_PORT );
}
static void rmq_ep_bind_out ( int slot, struct trtl_ep_address* addr )
{
uint32_t tmp;
uint32_t tmp;
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];
rmq_ep_out_writel( slot, tmp, TRTL_EP_OUT_MAC_HI );
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, 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->dst_ip, TRTL_EP_OUT_DST_IP );
rmq_ep_out_writel( slot, addr->src_port, TRTL_EP_OUT_SRC_PORT );
rmq_ep_out_writel( slot, addr->dst_port, TRTL_EP_OUT_DST_PORT );
tmp = ( (uint32_t)addr->dst_mac[0] << 8 ) | addr->dst_mac[1];
rmq_ep_out_writel( slot, tmp, TRTL_EP_OUT_MAC_HI );
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, 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->dst_ip, TRTL_EP_OUT_DST_IP );
rmq_ep_out_writel( slot, addr->src_port, TRTL_EP_OUT_SRC_PORT );
rmq_ep_out_writel( slot, addr->dst_port, TRTL_EP_OUT_DST_PORT );
}
void mq_bind(enum trtl_mq_type type, int slot, int is_out, struct trtl_ep_address* addr)
{
if( type != TRTL_RMQ )
{
pr_error("mq_bind() not supported on HMQ slots\n\r");
return;
}
if(is_out)
rmq_ep_bind_out( slot, addr );
else
rmq_ep_bind_in( slot, addr );
if( type != TRTL_RMQ )
{
pr_error("mq_bind() not supported on HMQ slots\n\r");
return;
}
if(is_out)
rmq_ep_bind_out( slot, addr );
else
rmq_ep_bind_in( slot, addr );
}
......@@ -11,6 +11,7 @@
#ifndef __MOCKTURTLE_RT_H
#define __MOCKTURTLE_RT_H
#include <errno.h>
#include <stdint.h>
#include <stdarg.h>
#include <generated/autoconf.h>
......@@ -450,17 +451,18 @@ static inline void *mq_map_in_header(enum trtl_mq_type type, int slot)
* @copydoc TRTL_MQ_CMD_CLAIM
* @param[in] type MQ type to use
* @param[in] slot slot number
* @return 1 on success, 0 if queue busy/full
* @return 0 on success, -EBUSY if queue busy/full
*/
static inline int mq_claim(enum trtl_mq_type type, int slot)
{
uint32_t status = mq_readl(type, TRTL_MQ_SLOT_OUT(slot) + TRTL_MQ_SLOT_STATUS);
if( status & TRTL_MQ_SLOT_STATUS_FULL )
return 0;
uint32_t status = mq_readl(type, TRTL_MQ_SLOT_OUT(slot) + TRTL_MQ_SLOT_STATUS);
mq_writel(type, TRTL_MQ_CMD_CLAIM, TRTL_MQ_SLOT_OUT(slot) + TRTL_MQ_SLOT_COMMAND);
return 1;
if( status & TRTL_MQ_SLOT_STATUS_FULL )
return -EBUSY;
mq_writel(type, TRTL_MQ_CMD_CLAIM,
TRTL_MQ_SLOT_OUT(slot) + TRTL_MQ_SLOT_COMMAND);
return 0;
}
/**
......@@ -487,13 +489,15 @@ static inline void mq_send(enum trtl_mq_type type, int slot)
}
/**
* Binds an RMQ slot to a particular IP configuration. Used when the Ethernet/UDP endpoint is enabled.
* Binds an RMQ slot to a particular IP configuration. Used when the Ethernet/UDP
* endpoint is enabled.
* @param[in] type MQ type to use
* @param[in] slot slot number
* @param[in] is_out non-zero if we're configuring an output slot
* @param[in] addr bind address
*/
void mq_bind(enum trtl_mq_type type, int slot, int is_out, struct trtl_ep_address* addr);
void mq_bind(enum trtl_mq_type type, int slot, int is_out,
struct trtl_ep_address* addr);
/**
......
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