Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Enumerations | Functions
tx.c File Reference
#include <linux/netdevice.h>
#include <linux/slab.h>
#include <linux/export.h>
#include "i2400m.h"
#include "debug-levels.h"

Go to the source code of this file.

Macros

#define D_SUBMODULE   tx
 
#define TAIL_FULL   ((void *)~(unsigned long)NULL)
 

Enumerations

enum  {
  I2400M_TX_BUF_SIZE = 65536, I2400M_TX_PLD_MAX = 60, I2400M_TX_PLD_SIZE, I2400M_TX_SKIP = 0x80000000,
  I2400M_TX_MSG_SIZE = 16384
}
 

Functions

int i2400m_tx (struct i2400m *i2400m, const void *buf, size_t buf_len, enum i2400m_pt pl_type)
 
 EXPORT_SYMBOL_GPL (i2400m_tx)
 
struct i2400m_msg_hdri2400m_tx_msg_get (struct i2400m *i2400m, size_t *bus_size)
 
 EXPORT_SYMBOL_GPL (i2400m_tx_msg_get)
 
void i2400m_tx_msg_sent (struct i2400m *i2400m)
 
 EXPORT_SYMBOL_GPL (i2400m_tx_msg_sent)
 
int i2400m_tx_setup (struct i2400m *i2400m)
 
void i2400m_tx_release (struct i2400m *i2400m)
 

Macro Definition Documentation

#define D_SUBMODULE   tx

Definition at line 252 of file tx.c.

#define TAIL_FULL   ((void *)~(unsigned long)NULL)

Definition at line 293 of file tx.c.

Enumeration Type Documentation

anonymous enum
Enumerator:
I2400M_TX_BUF_SIZE 

TX Buffer size

Doc says maximum transaction is 16KiB. If we had 16KiB en route and 16KiB being queued, it boils down to needing 32KiB. 32KiB is insufficient for 1400 MTU, hence increasing tx buffer size to 64KiB.

I2400M_TX_PLD_MAX 

Message header and payload descriptors have to be 16 aligned (16 + 4 * N = 16 * M). If we take that average sent packets are MTU size (~1400-~1500) it follows that we could fit at most 10-11 payloads in one transaction. To meet the alignment requirement, that means we need to leave space for 12 (64 bytes). To simplify, we leave space for that. If at the end there are less, we pad up to the nearest multiple of 16.

I2400M_TX_PLD_SIZE 
I2400M_TX_SKIP 
I2400M_TX_MSG_SIZE 

Definition at line 255 of file tx.c.

Function Documentation

EXPORT_SYMBOL_GPL ( i2400m_tx  )
EXPORT_SYMBOL_GPL ( i2400m_tx_msg_get  )
EXPORT_SYMBOL_GPL ( i2400m_tx_msg_sent  )
int i2400m_tx ( struct i2400m i2400m,
const void buf,
size_t  buf_len,
enum i2400m_pt  pl_type 
)

i2400m_tx - send the data in a buffer to the device

: pointer to the buffer to transmit

: buffer size

: type of the payload we are sending.

Returns: 0 if ok, < 0 errno code on error (-ENOSPC, if there is no more room for the message in the queue).

Appends the buffer to the TX FIFO and notifies the bus-specific part of the driver that there is new data ready to transmit. Once this function returns, the buffer has been copied, so it can be reused.

The steps followed to append are explained in detail in the file header.

Whenever we write to a message, we increase msg->size, so it reflects exactly how big the message is. This is needed so that if we concatenate two messages before they can be sent, the code that sends the messages can find the boundaries (and it will replace the size with the real barker before sending).

Note:

Cold and warm reset payloads need to be sent as a single
payload, so we handle that.

Definition at line 715 of file tx.c.

struct i2400m_msg_hdr* i2400m_tx_msg_get ( struct i2400m i2400m,
size_t bus_size 
)
read

i2400m_tx_msg_get - Get the first TX message in the FIFO to start sending it

: device descriptors : where to place the size of the TX message

Called by the bus-specific driver to get the first TX message at the FIF that is ready for transmission.

It sets the state in to indicate the bus-specific driver is transferring that message (i2400m->tx_msg_size).

Once the transfer is completed, call i2400m_tx_msg_sent().

Notes:

The size of the TX message to be transmitted might be smaller than
that of the TX message in the FIFO (in case the header was
shorter). Hence, we copy it in @bus_size, for the bus layer to
use. We keep the message's size in i2400m->tx_msg_size so that
when the bus later is done transferring we know how much to
advance the fifo.

We collect statistics here as all the data is available and we
assume it is going to work [see i2400m_tx_msg_sent()].

Definition at line 839 of file tx.c.

void i2400m_tx_msg_sent ( struct i2400m i2400m)

i2400m_tx_msg_sent - indicate the transmission of a TX message

: device descriptor

Called by the bus-specific driver when a message has been sent; this pops it from the FIFO; and as there is space, start the queue in case it was stopped.

Should be called even if the message send failed and we are dropping this TX message.

Definition at line 932 of file tx.c.

void i2400m_tx_release ( struct i2400m i2400m)

i2400m_tx_release - Tear down the TX queue and infrastructure

Definition at line 1006 of file tx.c.

int i2400m_tx_setup ( struct i2400m i2400m)

i2400m_tx_setup - Initialize the TX queue and infrastructure

Make sure we reset the TX sequence to zero, as when this function is called, the firmware has been just restarted. Same rational for tx_in, tx_out, tx_msg_size and tx_msg. We reset them since the memory for TX queue is reallocated.

Definition at line 965 of file tx.c.