本文整理汇总了C++中PDBG函数的典型用法代码示例。如果您正苦于以下问题:C++ PDBG函数的具体用法?C++ PDBG怎么用?C++ PDBG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PDBG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: handle_interrupt
static int
handle_interrupt (pixma_t * s, int timeout)
{
uint8_t buf[16];
int len;
len = pixma_wait_interrupt (s->io, buf, sizeof (buf), timeout);
if (len == PIXMA_ETIMEDOUT)
return 0;
if (len < 0)
return len;
switch (s->cfg->pid)
{
case MP360_PID:
case MP370_PID:
case MP375R_PID:
case MP390_PID:
case MF5730_PID:
case MF5750_PID:
case MF5770_PID:
case MF3110_PID:
case IR1020_PID:
if (len != 16)
{
PDBG (pixma_dbg
(1, "WARNING:unexpected interrupt packet length %d\n", len));
return PIXMA_EPROTO;
}
if (buf[12] & 0x40)
query_status (s);
if (buf[10] & 0x40)
send_time (s);
/* FIXME: following is unverified! */
if (buf[15] & 1)
s->events = PIXMA_EV_BUTTON2; /* b/w scan */
if (buf[15] & 2)
s->events = PIXMA_EV_BUTTON1; /* color scan */
break;
case MP5_PID:
case MP10_PID:
case MP700_PID:
case MP730_PID:
case MP710_PID:
case MP740_PID:
if (len != 8)
{
PDBG (pixma_dbg
(1, "WARNING:unexpected interrupt packet length %d\n", len));
return PIXMA_EPROTO;
}
if (buf[7] & 0x10)
s->events = PIXMA_EV_BUTTON1;
if (buf[5] & 8)
send_time (s);
break;
default:
PDBG (pixma_dbg (1, "WARNING:unknown interrupt, please report!\n"));
PDBG (pixma_hexdump (1, buf, len));
}
return 1;
}
开发者ID:Distrotech,项目名称:sane-backends,代码行数:63,代码来源:pixma_mp730.c
示例2: post_qp_event
static void post_qp_event(struct iwch_dev *rnicp, struct iwch_cq *chp,
struct respQ_msg_t *rsp_msg,
enum ib_event_type ib_event,
int send_term)
{
struct ib_event event;
struct iwch_qp_attributes attrs;
struct iwch_qp *qhp;
spin_lock(&rnicp->lock);
qhp = get_qhp(rnicp, CQE_QPID(rsp_msg->cqe));
if (!qhp) {
printk(KERN_ERR "%s unaffiliated error 0x%x qpid 0x%x\n",
__func__, CQE_STATUS(rsp_msg->cqe),
CQE_QPID(rsp_msg->cqe));
spin_unlock(&rnicp->lock);
return;
}
if ((qhp->attr.state == IWCH_QP_STATE_ERROR) ||
(qhp->attr.state == IWCH_QP_STATE_TERMINATE)) {
PDBG("%s AE received after RTS - "
"qp state %d qpid 0x%x status 0x%x\n", __func__,
qhp->attr.state, qhp->wq.qpid, CQE_STATUS(rsp_msg->cqe));
spin_unlock(&rnicp->lock);
return;
}
printk(KERN_ERR "%s - AE qpid 0x%x opcode %d status 0x%x "
"type %d wrid.hi 0x%x wrid.lo 0x%x \n", __func__,
CQE_QPID(rsp_msg->cqe), CQE_OPCODE(rsp_msg->cqe),
CQE_STATUS(rsp_msg->cqe), CQE_TYPE(rsp_msg->cqe),
CQE_WRID_HI(rsp_msg->cqe), CQE_WRID_LOW(rsp_msg->cqe));
atomic_inc(&qhp->refcnt);
spin_unlock(&rnicp->lock);
if (qhp->attr.state == IWCH_QP_STATE_RTS) {
attrs.next_state = IWCH_QP_STATE_TERMINATE;
iwch_modify_qp(qhp->rhp, qhp, IWCH_QP_ATTR_NEXT_STATE,
&attrs, 1);
if (send_term)
iwch_post_terminate(qhp, rsp_msg);
}
event.event = ib_event;
event.device = chp->ibcq.device;
if (ib_event == IB_EVENT_CQ_ERR)
event.element.cq = &chp->ibcq;
else
event.element.qp = &qhp->ibqp;
if (qhp->ibqp.event_handler)
(*qhp->ibqp.event_handler)(&event, qhp->ibqp.qp_context);
(*chp->ibcq.comp_handler)(&chp->ibcq, chp->ibcq.cq_context);
if (atomic_dec_and_test(&qhp->refcnt))
wake_up(&qhp->wait);
}
开发者ID:710leo,项目名称:LVS,代码行数:61,代码来源:iwch_ev.c
示例3: global_position
void QNitpickerPlatformWindow::_process_mouse_event(Input::Event *ev)
{
QPoint global_position(ev->ax(), ev->ay());
QPoint local_position(global_position.x() - geometry().x(),
global_position.y() - geometry().y());
//qDebug() << "local_position =" << local_position;
//qDebug() << "global_position =" << global_position;
switch (ev->type()) {
case Input::Event::PRESS:
if (qnpw_verbose)
PDBG("PRESS");
/* make this window the focused window */
requestActivateWindow();
switch (ev->code()) {
case Input::BTN_LEFT:
_mouse_button_state |= Qt::LeftButton;
break;
case Input::BTN_RIGHT:
_mouse_button_state |= Qt::RightButton;
break;
case Input::BTN_MIDDLE:
_mouse_button_state |= Qt::MidButton;
break;
case Input::BTN_SIDE:
_mouse_button_state |= Qt::XButton1;
break;
case Input::BTN_EXTRA:
_mouse_button_state |= Qt::XButton2;
break;
}
break;
case Input::Event::RELEASE:
if (qnpw_verbose)
PDBG("RELEASE");
switch (ev->code()) {
case Input::BTN_LEFT:
_mouse_button_state &= ~Qt::LeftButton;
break;
case Input::BTN_RIGHT:
_mouse_button_state &= ~Qt::RightButton;
break;
case Input::BTN_MIDDLE:
_mouse_button_state &= ~Qt::MidButton;
break;
case Input::BTN_SIDE:
_mouse_button_state &= ~Qt::XButton1;
break;
case Input::BTN_EXTRA:
_mouse_button_state &= ~Qt::XButton2;
break;
}
break;
case Input::Event::WHEEL:
if (qnpw_verbose)
PDBG("WHEEL");
QWindowSystemInterface::handleWheelEvent(window(),
local_position,
local_position,
ev->ry() * 120,
Qt::Vertical);
return;
default:
break;
}
QWindowSystemInterface::handleMouseEvent(window(),
local_position,
global_position,
_mouse_button_state);
}
开发者ID:OakDevel,项目名称:genode,代码行数:83,代码来源:qnitpickerplatformwindow.cpp
示例4: create_qp
static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
struct t4_cq *rcq, struct t4_cq *scq,
struct c4iw_dev_ucontext *uctx)
{
int user = (uctx != &rdev->uctx);
struct fw_ri_res_wr *res_wr;
struct fw_ri_res *res;
int wr_len;
struct c4iw_wr_wait wr_wait;
struct sk_buff *skb;
int ret;
int eqsize;
wq->sq.qid = c4iw_get_qpid(rdev, uctx);
if (!wq->sq.qid)
return -ENOMEM;
wq->rq.qid = c4iw_get_qpid(rdev, uctx);
if (!wq->rq.qid) {
ret = -ENOMEM;
goto free_sq_qid;
}
if (!user) {
wq->sq.sw_sq = kzalloc(wq->sq.size * sizeof *wq->sq.sw_sq,
GFP_KERNEL);
if (!wq->sq.sw_sq) {
ret = -ENOMEM;
goto free_rq_qid;
}
wq->rq.sw_rq = kzalloc(wq->rq.size * sizeof *wq->rq.sw_rq,
GFP_KERNEL);
if (!wq->rq.sw_rq) {
ret = -ENOMEM;
goto free_sw_sq;
}
}
/*
* RQT must be a power of 2.
*/
wq->rq.rqt_size = roundup_pow_of_two(wq->rq.size);
wq->rq.rqt_hwaddr = c4iw_rqtpool_alloc(rdev, wq->rq.rqt_size);
if (!wq->rq.rqt_hwaddr) {
ret = -ENOMEM;
goto free_sw_rq;
}
if (user) {
ret = alloc_oc_sq(rdev, &wq->sq);
if (ret)
goto free_hwaddr;
ret = alloc_host_sq(rdev, &wq->sq);
if (ret)
goto free_sq;
} else
ret = alloc_host_sq(rdev, &wq->sq);
if (ret)
goto free_hwaddr;
memset(wq->sq.queue, 0, wq->sq.memsize);
dma_unmap_addr_set(&wq->sq, mapping, wq->sq.dma_addr);
wq->rq.queue = dma_alloc_coherent(&(rdev->lldi.pdev->dev),
wq->rq.memsize, &(wq->rq.dma_addr),
GFP_KERNEL);
if (!wq->rq.queue) {
ret = -ENOMEM;
goto free_sq;
}
PDBG("%s sq base va 0x%p pa 0x%llx rq base va 0x%p pa 0x%llx\n",
__func__, wq->sq.queue,
(unsigned long long)virt_to_phys(wq->sq.queue),
wq->rq.queue,
(unsigned long long)virt_to_phys(wq->rq.queue));
memset(wq->rq.queue, 0, wq->rq.memsize);
dma_unmap_addr_set(&wq->rq, mapping, wq->rq.dma_addr);
wq->db = rdev->lldi.db_reg;
wq->gts = rdev->lldi.gts_reg;
if (user) {
wq->sq.udb = (u64)pci_resource_start(rdev->lldi.pdev, 2) +
(wq->sq.qid << rdev->qpshift);
wq->sq.udb &= PAGE_MASK;
wq->rq.udb = (u64)pci_resource_start(rdev->lldi.pdev, 2) +
(wq->rq.qid << rdev->qpshift);
wq->rq.udb &= PAGE_MASK;
}
wq->rdev = rdev;
wq->rq.msn = 1;
/* build fw_ri_res_wr */
wr_len = sizeof *res_wr + 2 * sizeof *res;
skb = alloc_skb(wr_len, GFP_KERNEL);
if (!skb) {
ret = -ENOMEM;
goto free_dma;
}
//.........这里部分代码省略.........
开发者ID:CoerWatt,项目名称:linux,代码行数:101,代码来源:qp.c
示例5: PDBG
struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries,
int vector, struct ib_ucontext *ib_context,
struct ib_udata *udata)
{
struct c4iw_dev *rhp;
struct c4iw_cq *chp;
struct c4iw_create_cq_resp uresp;
struct c4iw_ucontext *ucontext = NULL;
int ret;
size_t memsize, hwentries;
struct c4iw_mm_entry *mm, *mm2;
PDBG("%s ib_dev %p entries %d\n", __func__, ibdev, entries);
rhp = to_c4iw_dev(ibdev);
if (vector >= rhp->rdev.lldi.nciq)
return ERR_PTR(-EINVAL);
chp = kzalloc(sizeof(*chp), GFP_KERNEL);
if (!chp)
return ERR_PTR(-ENOMEM);
if (ib_context)
ucontext = to_c4iw_ucontext(ib_context);
/* account for the status page. */
entries++;
/* IQ needs one extra entry to differentiate full vs empty. */
entries++;
/*
* entries must be multiple of 16 for HW.
*/
entries = roundup(entries, 16);
/*
* Make actual HW queue 2x to avoid cdix_inc overflows.
*/
hwentries = min(entries * 2, T4_MAX_IQ_SIZE);
/*
* Make HW queue at least 64 entries so GTS updates aren't too
* frequent.
*/
if (hwentries < 64)
hwentries = 64;
memsize = hwentries * sizeof *chp->cq.queue;
/*
* memsize must be a multiple of the page size if its a user cq.
*/
if (ucontext) {
memsize = roundup(memsize, PAGE_SIZE);
hwentries = memsize / sizeof *chp->cq.queue;
while (hwentries > T4_MAX_IQ_SIZE) {
memsize -= PAGE_SIZE;
hwentries = memsize / sizeof *chp->cq.queue;
}
}
chp->cq.size = hwentries;
chp->cq.memsize = memsize;
chp->cq.vector = vector;
ret = create_cq(&rhp->rdev, &chp->cq,
ucontext ? &ucontext->uctx : &rhp->rdev.uctx);
if (ret)
goto err1;
chp->rhp = rhp;
chp->cq.size--; /* status page */
chp->ibcq.cqe = entries - 2;
spin_lock_init(&chp->lock);
spin_lock_init(&chp->comp_handler_lock);
atomic_set(&chp->refcnt, 1);
init_waitqueue_head(&chp->wait);
ret = insert_handle(rhp, &rhp->cqidr, chp, chp->cq.cqid);
if (ret)
goto err2;
if (ucontext) {
mm = kmalloc(sizeof *mm, GFP_KERNEL);
if (!mm)
goto err3;
mm2 = kmalloc(sizeof *mm2, GFP_KERNEL);
if (!mm2)
goto err4;
uresp.qid_mask = rhp->rdev.cqmask;
uresp.cqid = chp->cq.cqid;
uresp.size = chp->cq.size;
uresp.memsize = chp->cq.memsize;
spin_lock(&ucontext->mmap_lock);
uresp.key = ucontext->key;
ucontext->key += PAGE_SIZE;
uresp.gts_key = ucontext->key;
ucontext->key += PAGE_SIZE;
spin_unlock(&ucontext->mmap_lock);
//.........这里部分代码省略.........
开发者ID:MaxChina,项目名称:linux,代码行数:101,代码来源:cq.c
示例6: mp750_scan
static int
mp750_scan (pixma_t * s)
{
mp750_t *mp = (mp750_t *) s->subdriver;
int error;
uint8_t *buf;
unsigned size, dpi, spare;
dpi = s->param->ydpi;
/* add a stripe shift for 2400dpi */
mp->stripe_shift = (dpi == 2400) ? 4 : 0;
if (mp->state != state_idle)
return PIXMA_EBUSY;
/* clear interrupt packets buffer */
while (handle_interrupt (s, 0) > 0)
{
}
/* if (s->param->channels == 1)
mp->raw_width = ALIGN_SUP (s->param->w, 12);
else
mp->raw_width = ALIGN_SUP (s->param->w, 4);*/
/* change to use CCD grayscale mode --- why does this give segmentation error at runtime in mp750_check_param? */
if ((s->param->channels == 3) || (is_ccd_grayscale (s)))
mp->raw_width = ALIGN_SUP (s->param->w, 4);
else
mp->raw_width = ALIGN_SUP (s->param->w, 12);
/* not sure about MP750, but there is no need for aligning at 12 for the MP760/770, MP780/790 since always use CCD color mode */
/* modify for stripe shift */
spare = 2 * calc_component_shifting (s) + 2 * mp->stripe_shift; /* FIXME: or maybe (2*... + 1)? */
mp->raw_height = s->param->h + spare;
PDBG (pixma_dbg (3, "raw_width=%u raw_height=%u dpi=%u\n",
mp->raw_width, mp->raw_height, dpi));
/* PDBG (pixma_dbg (4, "line_size=%"PRIu64"\n",s->param->line_size)); */
mp->line_size = get_cis_ccd_line_size (s); /* scanner hardware line_size multiplied by 3 for CCD grayscale */
size = 8 + 2 * IMAGE_BLOCK_SIZE + spare * mp->line_size;
buf = (uint8_t *) malloc (size);
if (!buf)
return PIXMA_ENOMEM;
mp->buf = buf;
mp->rawimg = buf;
mp->imgbuf_ofs = spare * mp->line_size;
mp->imgcol = mp->rawimg + IMAGE_BLOCK_SIZE + 8; /* added to make rgb->gray */
mp->img = mp->rawimg + IMAGE_BLOCK_SIZE + 8;
mp->imgbuf_len = IMAGE_BLOCK_SIZE + mp->imgbuf_ofs;
mp->rawimg_left = 0;
mp->last_block_size = 0;
mp->shifted_bytes = -(int) mp->imgbuf_ofs;
error = step1 (s);
if (error >= 0)
error = start_session (s);
if (error >= 0)
mp->state = state_warmup;
if (error >= 0)
error = select_source (s);
if (error >= 0)
error = send_scan_param (s);
if (error < 0)
{
mp750_finish_scan (s);
return error;
}
return 0;
}
开发者ID:Ichoran,项目名称:lifespan,代码行数:72,代码来源:pixma_mp750.c
示例7: sizeof
void PluginStarter::_start_plugin(QString &file_name, QByteArray const &file_buf)
{
if (file_name.endsWith(".gz")) {
file_name.remove(".gz");
uint32_t file_size = *(uint32_t*)(file_buf.constData() + file_buf.size() - sizeof(uint32_t));
PDBG("file_size_uncompressed = %u", file_size);
size_t ram_quota = Genode::Arg_string::find_arg(_args.constData(), "ram_quota").long_value(0) + file_size;
if ((long)Genode::env()->ram_session()->avail() - (long)ram_quota < QPluginWidget::RAM_QUOTA) {
PERR("quota exceeded");
_plugin_loading_state = QUOTA_EXCEEDED_ERROR;
return;
}
QByteArray ram_quota_string("ram_quota=" + QByteArray::number((unsigned long long) ram_quota));
QByteArray ds_size_string("ds_size=" + QByteArray::number((unsigned long long)file_size));
QByteArray plugin_connection_args(ram_quota_string + "," + ds_size_string);
_pc = new Loader::Connection(plugin_connection_args.constData());
Genode::Dataspace_capability ds = _pc->dataspace();
if (ds.valid()) {
void *ds_addr = Genode::env()->rm_session()->attach(ds);
z_stream zs;
zs.next_in = (Bytef*)(file_buf.data());
zs.avail_in = file_buf.size();
zs.total_in = 0;
zs.next_out = (Bytef*)ds_addr;
zs.avail_out = file_size;
zs.total_out = 0;
zs.zalloc = Z_NULL;
zs.zfree = Z_NULL;
/* enable gzip format detection */
if (inflateInit2(&zs, 16 + MAX_WBITS) != Z_OK) {
PERR("inflateInit2() failed");
_plugin_loading_state = INFLATE_ERROR;
inflateEnd(&zs);
Genode::env()->rm_session()->detach(ds_addr);
return;
}
/* uncompress */
if (inflate(&zs, Z_SYNC_FLUSH) != Z_STREAM_END) {
PERR("inflate() failed");
_plugin_loading_state = INFLATE_ERROR;
inflateEnd(&zs);
Genode::env()->rm_session()->detach(ds_addr);
return;
}
inflateEnd(&zs);
Genode::env()->rm_session()->detach(ds_addr);
}
} else {
size_t ram_quota = Genode::Arg_string::find_arg(_args.constData(), "ram_quota").long_value(0);
if ((long)Genode::env()->ram_session()->avail() - (long)ram_quota < QPluginWidget::RAM_QUOTA) {
_plugin_loading_state = QUOTA_EXCEEDED_ERROR;
return;
}
QByteArray ram_quota_string("ram_quota=" + QByteArray::number((unsigned long long) ram_quota));
QByteArray ds_size_string("ds_size=" + QByteArray::number((unsigned long long)file_buf.size()));
QByteArray plugin_connection_args(ram_quota_string + "," + ds_size_string);
_pc = new Loader::Connection(plugin_connection_args.constData());
Genode::Dataspace_capability ds = _pc->dataspace();
if (ds.valid()) {
void *ds_addr = Genode::env()->rm_session()->attach(_pc->dataspace());
memcpy(ds_addr, file_buf.constData(), file_buf.size());
Genode::env()->rm_session()->detach(ds_addr);
}
}
try {
_pc->start(_args.constData(), _max_width, _max_height, 10000, file_name.toLatin1().constData());
_plugin_loading_state = LOADED;
} catch (Loader::Session::Rom_access_failed) {
_plugin_loading_state = ROM_CONNECTION_FAILED_EXCEPTION;
} catch (Loader::Session::Plugin_start_timed_out) {
_plugin_loading_state = TIMEOUT_EXCEPTION;
}
}
开发者ID:vishallinux,项目名称:genode,代码行数:92,代码来源:qpluginwidget.cpp
示例8: c4iw_poll_cq_one
/*
* Get one cq entry from c4iw and map it to openib.
*
* Returns:
* 0 cqe returned
* -ENODATA EMPTY;
* -EAGAIN caller must try again
* any other -errno fatal error
*/
static int c4iw_poll_cq_one(struct c4iw_cq *chp, struct ib_wc *wc)
{
struct c4iw_qp *qhp = NULL;
struct t4_cqe uninitialized_var(cqe), *rd_cqe;
struct t4_wq *wq;
u32 credit = 0;
u8 cqe_flushed;
u64 cookie = 0;
int ret;
ret = t4_next_cqe(&chp->cq, &rd_cqe);
if (ret)
return ret;
qhp = get_qhp(chp->rhp, CQE_QPID(rd_cqe));
if (!qhp)
wq = NULL;
else {
spin_lock(&qhp->lock);
wq = &(qhp->wq);
}
ret = poll_cq(wq, &(chp->cq), &cqe, &cqe_flushed, &cookie, &credit);
if (ret)
goto out;
wc->wr_id = cookie;
wc->qp = &qhp->ibqp;
wc->vendor_err = CQE_STATUS(&cqe);
wc->wc_flags = 0;
PDBG("%s qpid 0x%x type %d opcode %d status 0x%x len %u wrid hi 0x%x "
"lo 0x%x cookie 0x%llx\n", __func__, CQE_QPID(&cqe),
CQE_TYPE(&cqe), CQE_OPCODE(&cqe), CQE_STATUS(&cqe), CQE_LEN(&cqe),
CQE_WRID_HI(&cqe), CQE_WRID_LOW(&cqe), (unsigned long long)cookie);
if (CQE_TYPE(&cqe) == 0) {
if (!CQE_STATUS(&cqe))
wc->byte_len = CQE_LEN(&cqe);
else
wc->byte_len = 0;
wc->opcode = IB_WC_RECV;
if (CQE_OPCODE(&cqe) == FW_RI_SEND_WITH_INV ||
CQE_OPCODE(&cqe) == FW_RI_SEND_WITH_SE_INV) {
wc->ex.invalidate_rkey = CQE_WRID_STAG(&cqe);
wc->wc_flags |= IB_WC_WITH_INVALIDATE;
}
} else {
switch (CQE_OPCODE(&cqe)) {
case FW_RI_RDMA_WRITE:
wc->opcode = IB_WC_RDMA_WRITE;
break;
case FW_RI_READ_REQ:
wc->opcode = IB_WC_RDMA_READ;
wc->byte_len = CQE_LEN(&cqe);
break;
case FW_RI_SEND_WITH_INV:
case FW_RI_SEND_WITH_SE_INV:
wc->opcode = IB_WC_SEND;
wc->wc_flags |= IB_WC_WITH_INVALIDATE;
break;
case FW_RI_SEND:
case FW_RI_SEND_WITH_SE:
wc->opcode = IB_WC_SEND;
break;
case FW_RI_BIND_MW:
wc->opcode = IB_WC_BIND_MW;
break;
case FW_RI_LOCAL_INV:
wc->opcode = IB_WC_LOCAL_INV;
break;
case FW_RI_FAST_REGISTER:
wc->opcode = IB_WC_FAST_REG_MR;
break;
default:
printk(KERN_ERR MOD "Unexpected opcode %d "
"in the CQE received for QPID=0x%0x\n",
CQE_OPCODE(&cqe), CQE_QPID(&cqe));
ret = -EINVAL;
goto out;
}
}
if (cqe_flushed)
wc->status = IB_WC_WR_FLUSH_ERR;
else {
switch (CQE_STATUS(&cqe)) {
case T4_ERR_SUCCESS:
wc->status = IB_WC_SUCCESS;
//.........这里部分代码省略.........
开发者ID:MaxChina,项目名称:linux,代码行数:101,代码来源:cq.c
示例9: poll_cq
static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, struct t4_cqe *cqe,
u8 *cqe_flushed, u64 *cookie, u32 *credit)
{
int ret = 0;
struct t4_cqe *hw_cqe, read_cqe;
*cqe_flushed = 0;
*credit = 0;
ret = t4_next_cqe(cq, &hw_cqe);
if (ret)
return ret;
PDBG("%s CQE OVF %u qpid 0x%0x genbit %u type %u status 0x%0x"
" opcode 0x%0x len 0x%0x wrid_hi_stag 0x%x wrid_low_msn 0x%x\n",
__func__, CQE_OVFBIT(hw_cqe), CQE_QPID(hw_cqe),
CQE_GENBIT(hw_cqe), CQE_TYPE(hw_cqe), CQE_STATUS(hw_cqe),
CQE_OPCODE(hw_cqe), CQE_LEN(hw_cqe), CQE_WRID_HI(hw_cqe),
CQE_WRID_LOW(hw_cqe));
/*
*/
if (wq == NULL) {
ret = -EAGAIN;
goto skip_cqe;
}
/*
*/
if (RQ_TYPE(hw_cqe) && (CQE_OPCODE(hw_cqe) == FW_RI_READ_RESP)) {
/*
*/
if (!wq->sq.oldest_read) {
if (CQE_STATUS(hw_cqe))
t4_set_wq_in_error(wq);
ret = -EAGAIN;
goto skip_cqe;
}
/*
*/
create_read_req_cqe(wq, hw_cqe, &read_cqe);
hw_cqe = &read_cqe;
advance_oldest_read(wq);
}
if (CQE_STATUS(hw_cqe) || t4_wq_in_error(wq)) {
*cqe_flushed = t4_wq_in_error(wq);
t4_set_wq_in_error(wq);
goto proc_cqe;
}
if (CQE_OPCODE(hw_cqe) == FW_RI_TERMINATE) {
ret = -EAGAIN;
goto skip_cqe;
}
/*
*/
if (RQ_TYPE(hw_cqe)) {
/*
*/
if (t4_rq_empty(wq)) {
t4_set_wq_in_error(wq);
ret = -EAGAIN;
goto skip_cqe;
}
if (unlikely((CQE_WRID_MSN(hw_cqe) != (wq->rq.msn)))) {
t4_set_wq_in_error(wq);
hw_cqe->header |= htonl(V_CQE_STATUS(T4_ERR_MSN));
goto proc_cqe;
}
goto proc_cqe;
}
/*
//.........这里部分代码省略.........
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:101,代码来源:cq.c
示例10: PDBG
struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, int entries,
int vector, struct ib_ucontext *ib_context,
struct ib_udata *udata)
{
struct c4iw_dev *rhp;
struct c4iw_cq *chp;
struct c4iw_create_cq_resp uresp;
struct c4iw_ucontext *ucontext = NULL;
int ret;
size_t memsize, hwentries;
struct c4iw_mm_entry *mm, *mm2;
PDBG("%s ib_dev %p entries %d\n", __func__, ibdev, entries);
rhp = to_c4iw_dev(ibdev);
chp = kzalloc(sizeof(*chp), GFP_KERNEL);
if (!chp)
return ERR_PTR(-ENOMEM);
if (ib_context)
ucontext = to_c4iw_ucontext(ib_context);
/* */
entries++;
/* */
entries++;
/*
*/
entries = roundup(entries, 16);
/*
*/
hwentries = entries * 2;
/*
*/
if (hwentries < 64)
hwentries = 64;
memsize = hwentries * sizeof *chp->cq.queue;
/*
*/
if (ucontext) {
memsize = roundup(memsize, PAGE_SIZE);
hwentries = memsize / sizeof *chp->cq.queue;
while (hwentries > T4_MAX_IQ_SIZE) {
memsize -= PAGE_SIZE;
hwentries = memsize / sizeof *chp->cq.queue;
}
}
chp->cq.size = hwentries;
chp->cq.memsize = memsize;
ret = create_cq(&rhp->rdev, &chp->cq,
ucontext ? &ucontext->uctx : &rhp->rdev.uctx);
if (ret)
goto err1;
chp->rhp = rhp;
chp->cq.size--; /* */
chp->ibcq.cqe = entries - 2;
spin_lock_init(&chp->lock);
spin_lock_init(&chp->comp_handler_lock);
atomic_set(&chp->refcnt, 1);
init_waitqueue_head(&chp->wait);
ret = insert_handle(rhp, &rhp->cqidr, chp, chp->cq.cqid);
if (ret)
goto err2;
if (ucontext) {
mm = kmalloc(sizeof *mm, GFP_KERNEL);
if (!mm)
goto err3;
mm2 = kmalloc(sizeof *mm2, GFP_KERNEL);
if (!mm2)
goto err4;
uresp.qid_mask = rhp->rdev.cqmask;
uresp.cqid = chp->cq.cqid;
uresp.size = chp->cq.size;
uresp.memsize = chp->cq.memsize;
spin_lock(&ucontext->mmap_lock);
uresp.key = ucontext->key;
ucontext->key += PAGE_SIZE;
uresp.gts_key = ucontext->key;
ucontext->key += PAGE_SIZE;
spin_unlock(&ucontext->mmap_lock);
ret = ib_copy_to_udata(udata, &uresp, sizeof uresp);
if (ret)
goto err5;
//.........这里部分代码省略.........
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:101,代码来源:cq.c
示例11: build_phys_page_list
int build_phys_page_list(struct ib_phys_buf *buffer_list,
int num_phys_buf,
u64 *iova_start,
u64 *total_size,
int *npages,
int *shift,
__be64 **page_list)
{
u64 mask;
int i, j, n;
mask = 0;
*total_size = 0;
for (i = 0; i < num_phys_buf; ++i) {
if (i != 0 && buffer_list[i].addr & ~PAGE_MASK)
return -EINVAL;
if (i != 0 && i != num_phys_buf - 1 &&
(buffer_list[i].size & ~PAGE_MASK))
return -EINVAL;
*total_size += buffer_list[i].size;
if (i > 0)
mask |= buffer_list[i].addr;
else
mask |= buffer_list[i].addr & PAGE_MASK;
if (i != num_phys_buf - 1)
mask |= buffer_list[i].addr + buffer_list[i].size;
else
mask |= (buffer_list[i].addr + buffer_list[i].size +
PAGE_SIZE - 1) & PAGE_MASK;
}
if (*total_size > 0xFFFFFFFFULL)
return -ENOMEM;
/* Find largest page shift we can use to cover buffers */
for (*shift = PAGE_SHIFT; *shift < 27; ++(*shift))
if (num_phys_buf > 1) {
if ((1ULL << *shift) & mask)
break;
} else
if (1ULL << *shift >=
buffer_list[0].size +
(buffer_list[0].addr & ((1ULL << *shift) - 1)))
break;
buffer_list[0].size += buffer_list[0].addr & ((1ULL << *shift) - 1);
buffer_list[0].addr &= ~0ull << *shift;
*npages = 0;
for (i = 0; i < num_phys_buf; ++i)
*npages += (buffer_list[i].size +
(1ULL << *shift) - 1) >> *shift;
if (!*npages)
return -EINVAL;
*page_list = kmalloc(sizeof(u64) * *npages, GFP_KERNEL);
if (!*page_list)
return -ENOMEM;
n = 0;
for (i = 0; i < num_phys_buf; ++i)
for (j = 0;
j < (buffer_list[i].size + (1ULL << *shift) - 1) >> *shift;
++j)
(*page_list)[n++] = cpu_to_be64(buffer_list[i].addr +
((u64) j << *shift));
PDBG("%s va 0x%llx mask 0x%llx shift %d len %lld pbl_size %d\n",
__FUNCTION__, (unsigned long long) *iova_start,
(unsigned long long) mask, *shift, (unsigned long long) *total_size,
*npages);
return 0;
}
开发者ID:BackupTheBerlios,项目名称:grasshopper-svn,代码行数:76,代码来源:iwch_mem.c
示例12: mp730_fill_buffer
static int
mp730_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib)
{
int error, n;
mp730_t *mp = (mp730_t *) s->subdriver;
unsigned block_size, bytes_received;
uint8_t header[16];
do
{
do
{
if (s->cancel)
return PIXMA_ECANCELED;
if (mp->last_block) /* end of image */
return 0;
error = read_image_block (s, header, mp->imgbuf + mp->imgbuf_len);
if (error < 0)
return error;
bytes_received = error;
block_size = pixma_get_be16 (header + 4);
mp->last_block = ((header[2] & 0x28) == 0x28);
if (mp->last_block)
{ /* end of image */
mp->state = state_finished;
}
if ((header[2] & ~0x38) != 0)
{
PDBG (pixma_dbg (1, "WARNING: Unexpected result header\n"));
PDBG (pixma_hexdump (1, header, 16));
}
PASSERT (bytes_received == block_size);
if (block_size == 0)
{
/* no image data at this moment. */
/*pixma_sleep(100000); *//* FIXME: too short, too long? */
handle_interrupt (s, 100);
}
}
while (block_size == 0);
/* TODO: simplify! */
mp->imgbuf_len += bytes_received;
n = mp->imgbuf_len / s->param->line_size;
/* n = number of full lines (rows) we have in the buffer. */
if (n != 0)
{
if (s->param->channels != 1 &&
s->cfg->pid != MF5730_PID &&
s->cfg->pid != MF5750_PID &&
s->cfg->pid != MF5770_PID &&
s->cfg->pid != MF3110_PID &&
s->cfg->pid != IR1020_PID)
{
/* color, and not an MF57x0 nor MF3110 */
pack_rgb (mp->imgbuf, n, mp->raw_width, mp->lbuf);
}
else
/* grayscale/lineart or MF57x0 or MF3110 */
memcpy (mp->lbuf, mp->imgbuf, n * s->param->line_size);
block_size = n * s->param->line_size;
mp->imgbuf_len -= block_size;
memcpy (mp->imgbuf, mp->imgbuf + block_size, mp->imgbuf_len);
}
}
while (n == 0);
ib->rptr = mp->lbuf;
ib->rend = mp->lbuf + block_size;
return ib->rend - ib->rptr;
}
开发者ID:Distrotech,项目名称:sane-backends,代码行数:75,代码来源:pixma_mp730.c
示例13: step1
static int
step1 (pixma_t * s)
{
int error;
error = query_status (s);
if (error < 0)
return error;
if ((s->param->source == PIXMA_SOURCE_ADF
|| s->param->source == PIXMA_SOURCE_ADFDUP)
&& !has_paper (s))
return PIXMA_ENO_PAPER;
if (has_ccd_sensor (s))
{
switch (s->cfg->pid)
{
case MF5730_PID:
case MF5750_PID:
case MF5770_PID:
/* MF57x0: Wait 10 sec before starting for 1st page only */
if (s->param->adf_pageid == 0)
{
int tmo = 10; /* like Windows driver, 10 sec CCD calibration ? */
while (--tmo >= 0)
{
error = handle_interrupt (s, 1000); \
if (s->cancel) \
return PIXMA_ECANCELED; \
if (error != PIXMA_ECANCELED && error < 0) \
return error;
PDBG (pixma_dbg (2, "CCD Calibration ends in %d sec.\n", tmo));
}
}
break;
default:
break;
}
activate (s, 0);
error = calibrate (s);
switch (s->cfg->pid)
{
case MF5730_PID:
case MF5750_PID:
case MF5770_PID:
/* MF57x0: calibration returns PIXMA_STATUS_FAILED */
if (error == PIXMA_ECANCELED)
error = read_error_info (s, NULL, 0);
break;
default:
break;
}
}
if (error >= 0)
error = activate (s, 0);
if (error >= 0)
error = activate (s, 4);
return error;
}
开发者ID:Distrotech,项目名称:sane-backends,代码行数:62,代码来源:pixma_mp730.c
示例14: c4iw_flush_hw_cq
/*
* Move all CQEs from the HWCQ into the SWCQ.
* Deal with out-of-order and/or completions that complete
* prior unsignalled WRs.
*/
void c4iw_flush_hw_cq(struct c4iw_cq *chp)
{
struct t4_cqe *hw_cqe, *swcqe, read_cqe;
struct c4iw_qp *qhp;
struct t4_swsqe *swsqe;
int ret;
PDBG("%s cqid 0x%x\n", __func__, chp->cq.cqid);
ret = t4_next_hw_cqe(&chp->cq, &hw_cqe);
/*
* This logic is similar to poll_cq(), but not quite the same
* unfortunately. Need to move pertinent HW CQEs to the SW CQ but
* also do any translation magic that poll_cq() normally does.
*/
while (!ret) {
qhp = get_qhp(chp->rhp, CQE_QPID(hw_cqe));
/*
* drop CQEs with no associated QP
*/
if (qhp == NULL)
goto next_cqe;
if (CQE_OPCODE(hw_cqe) == FW_RI_TERMINATE)
goto next_cqe;
if (CQE_OPCODE(hw_cqe) == FW_RI_READ_RESP) {
/* If we have reached here because of async
* event or other error, and have egress error
* then drop
*/
if (CQE_TYPE(hw_cqe) == 1)
goto next_cqe;
/* drop peer2peer RTR reads.
*/
if (CQE_WRID_STAG(hw_cqe) == 1)
goto next_cqe;
/*
* Eat completions for unsignaled read WRs.
*/
if (!qhp->wq.sq.oldest_read->signaled) {
advance_oldest_read(&qhp->wq);
goto next_cqe;
}
/*
* Don't write to the HWCQ, create a new read req CQE
* in local memory and move it into the swcq.
*/
create_read_req_cqe(&qhp->wq, hw_cqe, &read_cqe);
hw_cqe = &read_cqe;
advance_oldest_read(&qhp->wq);
}
/* if its a SQ completion, then do the magic to move all the
* unsignaled and now in-order completions into the swcq.
*/
if (SQ_TYPE(hw_cqe)) {
swsqe = &qhp->wq.sq.sw_sq[CQE_WRID_SQ_IDX(hw_cqe)];
swsqe->cqe = *hw_cqe;
swsqe->complete = 1;
flush_completed_wrs(&qhp->wq, &chp->cq);
} else {
swcqe = &chp->cq.sw_queue[chp->cq.sw_pidx];
*swcqe = *hw_cqe;
swcqe->header |= cpu_to_be32(V_CQE_SWCQE(1));
t4_swcq_produce(&chp->cq);
}
next_cqe:
t4_hwcq_consume(&chp->cq);
ret = t4_next_hw_cqe(&chp->cq, &hw_cqe);
}
}
开发者ID:MaxChina,项目名称:linux,代码行数:82,代码来源:cq.c
示例15: poll_cq
/*
* poll_cq
*
* Caller must:
* check the validity of the first CQE,
* supply the wq assicated with the qpid.
*
* credit: cq credit to return to sge.
* cqe_flushed: 1 iff the CQE is flushed.
* cqe: copy of the polled CQE.
*
* return value:
* 0 CQE returned ok.
* -EAGAIN CQE skipped, try again.
* -EOVERFLOW CQ overflow detected.
*/
static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, struct t4_cqe *cqe,
u8 *cqe_flushed, u64 *cookie, u32 *credit)
{
int ret = 0;
struct t4_cqe *hw_cqe, read_cqe;
*cqe_flushed = 0;
*credit = 0;
ret = t4_next_cqe(cq, &hw_cqe);
if (ret)
return ret;
PDBG("%s CQE OVF %u qpid 0x%0x genbit %u type %u status 0x%0x"
" opcode 0x%0x len 0x%0x wrid_hi_stag 0x%x wrid_low_msn 0x%x\n",
__func__, CQE_OVFBIT(hw_cqe), CQE_QPID(hw_cqe),
CQE_GENBIT(hw_cqe), CQE_TYPE(hw_cqe), CQE_STATUS(hw_cqe),
CQE_OPCODE(hw_cqe), CQE_LEN(hw_cqe), CQE_WRID_HI(hw_cqe),
CQE_WRID_LOW(hw_cqe));
/*
* skip cqe's not affiliated with a QP.
*/
if (wq == NULL) {
ret = -EAGAIN;
goto skip_cqe;
}
/*
* skip hw cqe's if the wq is flushed.
*/
if (wq->flushed && !SW_CQE(hw_cqe)) {
ret = -EAGAIN;
goto skip_cqe;
}
/*
* skip TERMINATE cqes...
*/
if (CQE_OPCODE(hw_cqe) == FW_RI_TERMINATE) {
ret = -EAGAIN;
goto skip_cqe;
}
/*
* Gotta tweak READ completions:
* 1) the cqe doesn't contain the sq_wptr from the wr.
* 2) opcode not reflected from the wr.
* 3) read_len not reflected from the wr.
* 4) cq_type is RQ_TYPE not SQ_TYPE.
*/
if (RQ_TYPE(hw_cqe) && (CQE_OPCODE(hw_cqe) == FW_RI_READ_RESP)) {
/* If we have reached here because of async
* event or other error, and have egress error
* then drop
*/
if (CQE_TYPE(hw_cqe) == 1) {
if (CQE_STATUS(hw_cqe))
t4_set_wq_in_error(wq);
ret = -EAGAIN;
goto skip_cqe;
}
/* If this is an unsolicited read response, then the read
* was generated by the kernel driver as part of peer-2-peer
* connection setup. So ignore the completion.
*/
if (CQE_WRID_STAG(hw_cqe) == 1) {
if (CQE_STATUS(hw_cqe))
t4_set_wq_in_error(wq);
ret = -EAGAIN;
goto skip_cqe;
}
/*
* Eat completions for unsignaled read WRs.
*/
if (!wq->sq.oldest_read->signaled) {
advance_oldest_read(wq);
ret = -EAGAIN;
goto skip_cqe;
}
/*
//.........这里部分代码省略.........
开发者ID:MaxChina,项目名称:linux,代码行数:101,代码来源:cq.c
示例16: create_cq
static int create_cq(struct c4iw_rdev *rdev, struct t4_cq *cq,
struct c4iw_dev_ucontext *uctx)
{
struct fw_ri_res_wr *res_wr;
struct fw_ri_res *res;
int wr_len;
int user = (uctx != &rdev->uctx);
struct c4iw_wr_wait wr_wait;
int ret;
struct sk_buff *skb;
cq->cqid = c4iw_get_cqid(rdev, uctx);
if (!cq->cqid) {
ret = -ENOMEM;
goto err1;
}
if (!user) {
cq->sw_queue = kzalloc(cq->memsize, GFP_KERNEL);
if (!cq->sw_queue) {
ret = -ENOMEM;
goto err2;
}
}
cq->queue = dma_alloc_coherent(&rdev->lldi.pdev->dev, cq->memsize,
&cq->dma_addr, GFP_KERNEL);
if (!cq->queue) {
ret = -ENOMEM;
goto err3;
}
dma_unmap_addr_set(cq, mapping, cq->dma_addr);
memset(cq->queue, 0, cq->memsize);
/* build fw_ri_res_wr */
wr_len = sizeof *res_wr + sizeof *res;
skb = alloc_skb(wr_len, GFP_KERNEL);
if (!skb) {
ret = -ENOMEM;
goto err4;
}
set_wr_txq(skb, CPL_PRIORITY_CONTROL, 0);
res_wr = (struct fw_ri_res_wr *)__skb_put(skb, wr_len);
memset(res_wr, 0, wr_len);
res_wr->op_nres = cpu_to_be32(
FW_WR_OP(FW_RI_RES_WR) |
V_FW_RI_RES_WR_NRES(1) |
FW_WR_COMPL(1));
res_wr->len16_pkd = cpu_to_be32(DIV_ROUND_UP(wr_len, 16));
res_wr->cookie = (unsigned long) &wr_wait;
res = res_wr->res;
res->u.cq.restype = FW_RI_RES_TYPE_CQ;
res->u.cq.op = FW_RI_RES_OP_WRITE;
res->u.cq.iqid = cpu_to_be32(cq->cqid);
res->u.cq.iqandst_to_iqandstindex = cpu_to_be32(
V_FW_RI_RES_WR_IQANUS(0) |
V_FW_RI_RES_WR_IQANUD(1) |
F_FW_RI_RES_WR_IQANDST |
V_FW_RI_RES_WR_IQANDSTINDEX(
rdev->lldi.ciq_ids[cq->vector]));
res->u.cq.iqdroprss_to_iqesize = cpu_to_be16(
F_FW_RI_RES_WR_IQDROPRSS |
V_FW_RI_RES_WR_IQPCIECH(2) |
V_FW_RI_RES_WR_IQINTCNTTHRESH(0) |
F_FW_RI_RES_WR_IQO |
V_FW_RI_RES_WR_IQESIZE(1));
res->u.cq.iqsize = cpu_to_be16(cq->size);
res->u.cq.iqaddr = cpu_to_be64(cq->dma_addr);
c4iw_init_wr_wait(&wr_wait);
ret = c4iw_ofld_send(rdev, skb);
if (ret)
goto err4;
PDBG("%s wait_event wr_wait %p\n", __func__, &wr_wait);
ret = c4iw_wait_for_reply(rdev, &wr_wait, 0, 0, __func__);
if (ret)
goto err4;
cq->gen = 1;
cq->gts = rdev->lldi.gts_reg;
cq->rdev = rdev;
if (user) {
cq->ugts = (u64)pci_resource_start(rdev->lldi.pdev, 2) +
(cq->cqid << rdev->cqshift);
cq->ugts &= PAGE_MASK;
}
return 0;
err4:
dma_free_coherent(&rdev->lldi.pdev->dev, cq->memsize, cq->queue,
dma_unmap_addr(cq, mapping));
err3:
kfree(cq->sw_queue);
err2:
c4iw_put_cqid(rdev, cq->cqid, uctx);
err1:
return ret;
}
开发者ID:MaxChina,项目名称:linux,代码行数:99,代码来源:cq.c
示例17: iwch_resize_cq
static int iwch_resize_cq(struct ib_cq *cq, int cqe, struct ib_udata *udata)
{
#ifdef notyet
struct iwch_cq *chp = to_iwch_cq(cq);
struct t3_cq oldcq, newcq;
int ret;
PDBG("%s ib_cq %p cqe %d\n", __func__, cq, cqe);
/* We don't downsize... */
if (cqe <= cq->cqe)
return 0;
/* create new t3_cq with new size */
cqe = roundup_pow_of_two(cqe+1);
newcq.size_log2 = ilog2(cqe);
/* Dont allow resize to less than the current wce count */
if (cqe < Q_COUNT(chp->cq.rptr, chp->cq.wptr)) {
return -ENOMEM;
}
/* Quiesce all QPs using this CQ */
ret = iwch_quiesce_qps(chp);
if (ret) {
return ret;
}
ret = cxio_create_cq(&chp->rhp->rdev, &newcq);
if (ret) {
return ret;
}
/* copy CQEs */
memcpy(newcq.queue, chp->cq.queue, (1 << chp->cq.size_log2) *
sizeof(struct t3_cqe));
/* old iwch_qp gets new t3_cq but keeps old cqid */
oldcq = chp->cq;
chp->cq = newcq;
chp->cq.cqid = oldcq.cqid;
/* resize new t3_cq to update the HW context */
ret = cxio_resize_cq(&chp->rhp->rdev, &chp->cq);
if (ret) {
chp->cq = oldcq;
return ret;
}
chp->ibcq.cqe = (1<<chp->cq.size_log2) - 1;
/* destroy old t3_cq */
oldcq.cqid = newcq.cqid;
ret = cxio_destroy_cq(&chp->rhp->rdev, &oldcq);
if (ret) {
printk(KERN_ERR MOD "%s - cxio_destroy_cq failed %d\n",
__func__, ret);
}
/* add user hooks here */
/* resume qps */
ret = iwch_resume_qps(chp);
return ret;
#else
return -ENOSYS;
#endif
}
开发者ID:A2109devs,项目名称:lenovo_a2109a_kernel,代码行数:67,代码来源:iwch_provider.c
示例18: main
int main(int argc, char * argv[])
{
const char * config_file_name = NULL;
bool daemon_mode = true;
pid_t pid;
/* Search command line for config file name
* */
for ( int i = 1; i < argc; ++i ) {
if ( strncmp(argv[i], "--config=", 9) == 0 ) {
config_file_name = argv[i] + 9;
|
请发表评论