struct fdma_ops { /* User-provided callback to set the dataptr */ int (*dataptr_cb)(struct fdma *fdma, int dcb_idx, int db_idx, u64 *ptr); /* User-provided callback to set the nextptr */ int (*nextptr_cb)(struct fdma *fdma, int dcb_idx, u64 *ptr);
};
/* Indexes used to access the next-to-be-used DCB or DB */ int db_index; int dcb_index;
/* Number of DCB's and DB's */
u32 n_dcbs;
u32 n_dbs;
/* Size of DB's */
u32 db_size;
/* Channel id this FDMA object operates on */
u32 channel_id;
struct fdma_ops ops;
};
/* Advance the DCB index and wrap if required. */ staticinlinevoid fdma_dcb_advance(struct fdma *fdma)
{
fdma->dcb_index++; if (fdma->dcb_index >= fdma->n_dcbs)
fdma->dcb_index = 0;
}
/* Advance the DB index. */ staticinlinevoid fdma_db_advance(struct fdma *fdma)
{
fdma->db_index++;
}
/* Reset the db index to zero. */ staticinlinevoid fdma_db_reset(struct fdma *fdma)
{
fdma->db_index = 0;
}
/* Check if a DCB can be reused in case of multiple DB's per DCB. */ staticinlinebool fdma_dcb_is_reusable(struct fdma *fdma)
{ return fdma->db_index != fdma->n_dbs;
}
/* Check if the FDMA has marked this DB as done. */ staticinlinebool fdma_db_is_done(struct fdma_db *db)
{ return db->status & FDMA_DCB_STATUS_DONE;
}
/* Get the length of a DB. */ staticinlineint fdma_db_len_get(struct fdma_db *db)
{ return FDMA_DCB_STATUS_BLOCKL(db->status);
}
/* Set the length of a DB. */ staticinlinevoid fdma_dcb_len_set(struct fdma_dcb *dcb, u32 len)
{
dcb->info = FDMA_DCB_INFO_DATAL(len);
}
/* Get a DB by index. */ staticinlinestruct fdma_db *fdma_db_get(struct fdma *fdma, int dcb_idx, int db_idx)
{ return &fdma->dcbs[dcb_idx].db[db_idx];
}
/* Get the next DB. */ staticinlinestruct fdma_db *fdma_db_next_get(struct fdma *fdma)
{ return fdma_db_get(fdma, fdma->dcb_index, fdma->db_index);
}
/* Get a DCB by index. */ staticinlinestruct fdma_dcb *fdma_dcb_get(struct fdma *fdma, int dcb_idx)
{ return &fdma->dcbs[dcb_idx];
}
/* Get the next DCB. */ staticinlinestruct fdma_dcb *fdma_dcb_next_get(struct fdma *fdma)
{ return fdma_dcb_get(fdma, fdma->dcb_index);
}
/* Check if the FDMA has frames ready for extraction. */ staticinlinebool fdma_has_frames(struct fdma *fdma)
{ return fdma_db_is_done(fdma_db_next_get(fdma));
}
/* Get a nextptr by index */ staticinlineint fdma_nextptr_cb(struct fdma *fdma, int dcb_idx, u64 *nextptr)
{
*nextptr = fdma->dma + (sizeof(struct fdma_dcb) * dcb_idx); return 0;
}
/* Get the DMA address of a dataptr, by index. This function is only applicable * if the dataptr addresses and DCB's are in contiguous memory and the driver * supports XDP.
*/ staticinline u64 fdma_dataptr_get_contiguous(struct fdma *fdma, int dcb_idx, int db_idx)
{ return fdma->dma + (sizeof(struct fdma_dcb) * fdma->n_dcbs) +
(dcb_idx * fdma->n_dbs + db_idx) * fdma->db_size +
XDP_PACKET_HEADROOM;
}
/* Get the virtual address of a dataptr, by index. This function is only * applicable if the dataptr addresses and DCB's are in contiguous memory and * the driver supports XDP.
*/ staticinlinevoid *fdma_dataptr_virt_get_contiguous(struct fdma *fdma, int dcb_idx, int db_idx)
{ return (u8 *)fdma->dcbs + (sizeof(struct fdma_dcb) * fdma->n_dcbs) +
(dcb_idx * fdma->n_dbs + db_idx) * fdma->db_size +
XDP_PACKET_HEADROOM;
}
/* Check if this DCB is the last used DCB. */ staticinlinebool fdma_is_last(struct fdma *fdma, struct fdma_dcb *dcb)
{ return dcb == fdma->last_dcb;
}
int fdma_dcbs_init(struct fdma *fdma, u64 info, u64 status); int fdma_db_add(struct fdma *fdma, int dcb_idx, int db_idx, u64 status); int fdma_dcb_add(struct fdma *fdma, int dcb_idx, u64 info, u64 status); int __fdma_dcb_add(struct fdma *fdma, int dcb_idx, u64 info, u64 status, int (*dcb_cb)(struct fdma *fdma, int dcb_idx, u64 *nextptr), int (*db_cb)(struct fdma *fdma, int dcb_idx, int db_idx,
u64 *dataptr));
int fdma_alloc_coherent(struct device *dev, struct fdma *fdma); int fdma_alloc_phys(struct fdma *fdma);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.