本文整理汇总了C++中sg_virt函数的典型用法代码示例。如果您正苦于以下问题:C++ sg_virt函数的具体用法?C++ sg_virt怎么用?C++ sg_virt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sg_virt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hv_ringbuffer_write
/*
*
* hv_ringbuffer_write()
*
* Write to the ring buffer
*
*/
int hv_ringbuffer_write(struct hv_ring_buffer_info *outring_info,
struct scatterlist *sglist, u32 sgcount)
{
int i = 0;
u32 bytes_avail_towrite;
u32 bytes_avail_toread;
u32 totalbytes_towrite = 0;
struct scatterlist *sg;
u32 next_write_location;
u64 prev_indices = 0;
unsigned long flags;
for_each_sg(sglist, sg, sgcount, i)
{
totalbytes_towrite += sg->length;
}
totalbytes_towrite += sizeof(u64);
spin_lock_irqsave(&outring_info->ring_lock, flags);
hv_get_ringbuffer_availbytes(outring_info,
&bytes_avail_toread,
&bytes_avail_towrite);
/* If there is only room for the packet, assume it is full. */
/* Otherwise, the next time around, we think the ring buffer */
/* is empty since the read index == write index */
if (bytes_avail_towrite <= totalbytes_towrite) {
spin_unlock_irqrestore(&outring_info->ring_lock, flags);
return -1;
}
/* Write to the ring buffer */
next_write_location = hv_get_next_write_location(outring_info);
for_each_sg(sglist, sg, sgcount, i)
{
next_write_location = hv_copyto_ringbuffer(outring_info,
next_write_location,
sg_virt(sg),
sg->length);
}
示例2: process_request
/*---------------------------------------------------------------------------*/
static void process_request(struct xio_msg *msg)
{
static int cnt;
if (!msg) {
cnt = 0;
return;
}
if (++cnt == PRINT_COUNTER) {
struct scatterlist *sgl = msg->in.data_tbl.sgl;
pr_info("**** message [%llu] %s - %s\n",
(msg->sn + 1),
(char *)msg->in.header.iov_base,
(char *)sg_virt(sgl));
cnt = 0;
}
}
示例3: dma_unmap_sg
void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
enum dma_data_direction direction)
{
unsigned long addr;
int i;
BUG_ON(direction == DMA_NONE);
for (i = 0; i < nhwentries; i++, sg++) {
if (!plat_device_is_coherent(dev) &&
direction != DMA_TO_DEVICE) {
addr = (unsigned long) sg_virt(sg);
if (addr)
__dma_sync(addr, sg->length, direction);
}
plat_unmap_dma_mem(dev, sg->dma_address, sg->length, direction);
}
}
示例4: sh_mmcif_multi_read
static void sh_mmcif_multi_read(struct sh_mmcif_host *host,
struct mmc_request *mrq)
{
struct mmc_data *data = mrq->data;
if (!data->sg_len || !data->sg->length)
return;
host->blocksize = sh_mmcif_readl(host->addr, MMCIF_CE_BLOCK_SET) &
BLOCK_SIZE_MASK;
host->wait_for = MMCIF_WAIT_FOR_MREAD;
host->sg_idx = 0;
host->sg_blkidx = 0;
host->pio_ptr = sg_virt(data->sg);
schedule_delayed_work(&host->timeout_work, host->timeout);
sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFREN);
}
示例5: sh_mmcif_multi_write
static void sh_mmcif_multi_write(struct sh_mmcif_host *host,
struct mmc_request *mrq)
{
struct mmc_data *data = mrq->data;
if (!data->sg_len || !data->sg->length)
return;
host->blocksize = sh_mmcif_readl(host->addr, MMCIF_CE_BLOCK_SET) &
BLOCK_SIZE_MASK;
host->wait_for = MMCIF_WAIT_FOR_MWRITE;
host->sg_idx = 0;
host->sg_blkidx = 0;
host->pio_ptr = sg_virt(data->sg);
sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFWEN);
}
示例6: dma_map_sg
int
dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
enum dma_data_direction direction)
{
int i;
BUG_ON(direction == DMA_NONE);
for (i = 0; i < nents; i++, sg++) {
sg->dma_address = (dma_addr_t) sg_virt(sg);
invalidate_dcache_range(sg_dma_address(sg),
sg_dma_address(sg) +
sg_dma_len(sg));
}
return nents;
}
示例7: pmpmci_receive_pio
static void pmpmci_receive_pio(struct pmpmci_host *host)
{
struct mmc_data *data;
struct sd_data_s *sd_data= host->platdata;
int max, count, sg_len = 0;
unsigned int *sg_ptr = NULL;
struct scatterlist *sg;
data = host->mrq->data;
if (!(host->flags & HOST_F_RECV))
return;
max = host->pio.len;
if (host->pio.index < host->dma.sgmap_len) {
sg = &data->sg[host->pio.index];
sg_ptr = sg_virt(sg) + host->pio.offset;
sg_len = sg_dma_len(&data->sg[host->pio.index]) - host->pio.offset;
if (sg_len < max)
max = sg_len;
}
count = sd_data->ops->transData(&(sd_data->info),
SD_DATA_FIFO | SD_DATA_READ,
(void *)sg_ptr,
max);
host->pio.len -= count;
host->pio.offset += count;
if (sg_len && count == sg_len) {
host->pio.index++;
host->pio.offset = 0;
}
if (host->pio.len == 0) {
sd_data->ops->intrpt_enable(&(sd_data->info),
SD_MMC_INT_DATABUFFULL ,
0);
host->flags &= ~(HOST_F_XMIT | HOST_F_RECV);
//printk("\n%s(),%d.", __FUNCTION__, __LINE__);
//tasklet_schedule(&host->data_task);
pmpmci_data_complete(host, sd_data->ops->getStatus(&(sd_data->info)));
}
}
示例8: pmpmci_send_pio
static void pmpmci_send_pio(struct pmpmci_host *host)
{
struct mmc_data *data;
struct sd_data_s *sd_data= host->platdata;
int sg_len, max, count;
unsigned int *sg_ptr;
struct scatterlist *sg;
data = host->mrq->data;
if (!(host->flags & HOST_F_XMIT))
return;
sg = &data->sg[host->pio.index];
sg_ptr = sg_virt(sg) + host->pio.offset;
sg_len = data->sg[host->pio.index].length - host->pio.offset;
max = (sg_len > host->pio.len) ? host->pio.len : sg_len;
count = sd_data->ops->transData(&(sd_data->info),
SD_DATA_FIFO | SD_DATA_WRITE,
(void *)sg_ptr,
max);
host->pio.len -= count;
host->pio.offset += count;
if (count == sg_len) {
host->pio.index++;
host->pio.offset = 0;
}
if (host->pio.len == 0) {
sd_data->ops->intrpt_enable(&(sd_data->info),
SD_MMC_INT_DATABUFEMPTY ,
0);
host->flags &= ~(HOST_F_XMIT | HOST_F_RECV);
//printk("\n%s(),%d.", __FUNCTION__, __LINE__);
//tasklet_schedule(&host->data_task);
pmpmci_data_complete(host, sd_data->ops->getStatus(&(sd_data->info)));
}
}
示例9: process_request
/*---------------------------------------------------------------------------*/
static void process_request(struct xio_msg *req)
{
struct sg_table *sgt = &req->in.data_tbl;
struct scatterlist *sg;
char *str;
int len, i;
char tmp;
/* note all data is packed together so in order to print each
* part on its own NULL character is temporarily stuffed
* before the print and the original character is restored after
* the printf
*/
if (++g_server_data->cnt == PRINT_COUNTER) {
str = (char *)req->in.header.iov_base;
len = req->in.header.iov_len;
if (str) {
if (((unsigned)len) > 64)
len = 64;
tmp = str[len];
str[len] = '\0';
pr_info("message header : [%llu] - %s\n",
(req->sn + 1), str);
str[len] = tmp;
}
sg = sgt->sgl;
for (i = 0; i < sgt->nents; i++) {
str = (char *)sg_virt(sg);
len = sg->length;
if (str) {
if (((unsigned)len) > 64)
len = 64;
tmp = str[len];
str[len] = '\0';
pr_info("message data: [%llu][%d][%d] - %s\n",
(req->sn + 1), i, len, str);
str[len] = tmp;
}
sg = sg_next(sg);
}
g_server_data->cnt = 0;
}
}
示例10: __alloc_pbl
static int __alloc_pbl(struct pci_dev *pdev, struct bnxt_qplib_pbl *pbl,
struct scatterlist *sghead, u32 pages, u32 pg_size)
{
struct scatterlist *sg;
bool is_umem = false;
int i;
/* page ptr arrays */
pbl->pg_arr = kcalloc(pages, sizeof(void *), GFP_KERNEL);
if (!pbl->pg_arr)
return -ENOMEM;
pbl->pg_map_arr = kcalloc(pages, sizeof(dma_addr_t), GFP_KERNEL);
if (!pbl->pg_map_arr) {
kfree(pbl->pg_arr);
pbl->pg_arr = NULL;
return -ENOMEM;
}
pbl->pg_count = 0;
pbl->pg_size = pg_size;
if (!sghead) {
for (i = 0; i < pages; i++) {
pbl->pg_arr[i] = dma_zalloc_coherent(&pdev->dev,
pbl->pg_size,
&pbl->pg_map_arr[i],
GFP_KERNEL);
if (!pbl->pg_arr[i])
goto fail;
pbl->pg_count++;
}
} else {
i = 0;
is_umem = true;
for_each_sg(sghead, sg, pages, i) {
pbl->pg_map_arr[i] = sg_dma_address(sg);
pbl->pg_arr[i] = sg_virt(sg);
if (!pbl->pg_arr[i])
goto fail;
pbl->pg_count++;
}
}
示例11: mt76x02u_mcu_wait_resp
static int mt76x02u_mcu_wait_resp(struct mt76_dev *dev, u8 seq)
{
struct mt76_usb *usb = &dev->usb;
struct mt76u_buf *buf = &usb->mcu.res;
struct urb *urb = buf->urb;
int i, ret;
u32 rxfce;
u8 *data;
for (i = 0; i < 5; i++) {
if (!wait_for_completion_timeout(&usb->mcu.cmpl,
msecs_to_jiffies(300)))
continue;
if (urb->status)
return -EIO;
data = sg_virt(&urb->sg[0]);
if (usb->mcu.rp)
mt76x02u_multiple_mcu_reads(dev, data + 4,
urb->actual_length - 8);
rxfce = get_unaligned_le32(data);
ret = mt76u_submit_buf(dev, USB_DIR_IN,
MT_EP_IN_CMD_RESP,
buf, GFP_KERNEL,
mt76u_mcu_complete_urb,
&usb->mcu.cmpl);
if (ret)
return ret;
if (seq == FIELD_GET(MT_RX_FCE_INFO_CMD_SEQ, rxfce) &&
FIELD_GET(MT_RX_FCE_INFO_EVT_TYPE, rxfce) == EVT_CMD_DONE)
return 0;
dev_err(dev->dev, "error: MCU resp evt:%lx seq:%hhx-%lx\n",
FIELD_GET(MT_RX_FCE_INFO_EVT_TYPE, rxfce),
seq, FIELD_GET(MT_RX_FCE_INFO_CMD_SEQ, rxfce));
}
dev_err(dev->dev, "error: %s timed out\n", __func__);
return -ETIMEDOUT;
}
示例12: dma_map_sg
int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
enum dma_data_direction direction)
{
int i;
BUG_ON(direction == DMA_NONE);
for (i = 0; i < nents; i++, sg++) {
unsigned long addr;
addr = (unsigned long) sg_virt(sg);
if (!plat_device_is_coherent(dev) && addr)
__dma_sync(addr, sg->length, direction);
sg->dma_address = plat_map_dma_mem(dev,
(void *)addr, sg->length);
}
return nents;
}
示例13: sh_mmcif_next_block
static bool sh_mmcif_next_block(struct sh_mmcif_host *host, u32 *p)
{
struct mmc_data *data = host->mrq->data;
host->sg_blkidx += host->blocksize;
/* data->sg->length must be a multiple of host->blocksize? */
BUG_ON(host->sg_blkidx > data->sg->length);
if (host->sg_blkidx == data->sg->length) {
host->sg_blkidx = 0;
if (++host->sg_idx < data->sg_len)
host->pio_ptr = sg_virt(++data->sg);
} else {
host->pio_ptr = p;
}
return host->sg_idx != data->sg_len;
}
示例14: mt76u_process_rx_entry
static int
mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb)
{
struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN];
u8 *data = sg_virt(&urb->sg[0]);
int data_len, len, nsgs = 1;
struct sk_buff *skb;
if (!test_bit(MT76_STATE_INITIALIZED, &dev->state))
return 0;
len = mt76u_get_rx_entry_len(data, urb->actual_length);
if (len < 0)
return 0;
skb = build_skb(data, q->buf_size);
if (!skb)
return 0;
data_len = min_t(int, len, urb->sg[0].length - MT_DMA_HDR_LEN);
skb_reserve(skb, MT_DMA_HDR_LEN);
if (skb->tail + data_len > skb->end) {
dev_kfree_skb(skb);
return 1;
}
__skb_put(skb, data_len);
len -= data_len;
while (len > 0) {
data_len = min_t(int, len, urb->sg[nsgs].length);
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
sg_page(&urb->sg[nsgs]),
urb->sg[nsgs].offset,
data_len, q->buf_size);
len -= data_len;
nsgs++;
}
dev->drv->rx_skb(dev, MT_RXQ_MAIN, skb);
return nsgs;
}
示例15: mts_build_transfer_context
static void
mts_build_transfer_context(struct scsi_cmnd *srb, struct mts_desc* desc)
{
int pipe;
struct scatterlist * sg;
MTS_DEBUG_GOT_HERE();
desc->context.instance = desc;
desc->context.srb = srb;
desc->context.fragment = 0;
if (!scsi_bufflen(srb)) {
desc->context.data = NULL;
desc->context.data_length = 0;
return;
} else {
sg = scsi_sglist(srb);
desc->context.data = sg_virt(&sg[0]);
desc->context.data_length = sg[0].length;
}
/* can't rely on srb->sc_data_direction */
/* Brutally ripped from usb-storage */
if ( !memcmp( srb->cmnd, mts_read_image_sig, mts_read_image_sig_len )
) { pipe = usb_rcvbulkpipe(desc->usb_dev,desc->ep_image);
MTS_DEBUG( "transfering from desc->ep_image == %d\n",
(int)desc->ep_image );
} else if ( MTS_DIRECTION_IS_IN(srb->cmnd[0]) ) {
pipe = usb_rcvbulkpipe(desc->usb_dev,desc->ep_response);
MTS_DEBUG( "transfering from desc->ep_response == %d\n",
(int)desc->ep_response);
} else {
MTS_DEBUG("transfering to desc->ep_out == %d\n",
(int)desc->ep_out);
pipe = usb_sndbulkpipe(desc->usb_dev,desc->ep_out);
}
desc->context.data_pipe = pipe;
}