Exemple #1
0
static int nitrox_sriov_enable(struct pci_dev *pdev, int num_vfs)
{
	struct nitrox_device *ndev = pci_get_drvdata(pdev);
	int err;

	if (!num_vfs_valid(num_vfs)) {
		dev_err(DEV(ndev), "Invalid num_vfs %d\n", num_vfs);
		return -EINVAL;
	}

	if (pci_num_vf(pdev) == num_vfs)
		return num_vfs;

	err = pci_enable_sriov(pdev, num_vfs);
	if (err) {
		dev_err(DEV(ndev), "failed to enable PCI sriov %d\n", err);
		return err;
	}
	dev_info(DEV(ndev), "Enabled VF(s) %d\n", num_vfs);

	ndev->num_vfs = num_vfs;
	ndev->mode = num_vfs_to_mode(num_vfs);
	/* set bit in flags */
	set_bit(__NDEV_SRIOV_BIT, &ndev->flags);

	/* cleanup PF resources */
	pf_sriov_cleanup(ndev);

	config_nps_core_vfcfg_mode(ndev, ndev->mode);

	return num_vfs;
}
Exemple #2
0
painter_t *
svg_painter_new (window_t * window, const char *filename)
{
  svg_painter_t *this = g_new0 (svg_painter_t, 1);

  painter_t *parent = (painter_t *) this;
  double bbox[4];
  double graph_width = window->width;
  double graph_height = window->height;

  // This should be configurable
  double paper_height = 842;
  double paper_width = 595;

  // Don't need these two statements, do I?
  parent->area_w = window->width;
  parent->area_h = window->height;

  parent->set_attributes = svg_painter_set_attributes;
  parent->draw_segments = svg_painter_draw_segments;
  parent->draw_marks = svg_painter_draw_marks;
  parent->draw_line = svg_painter_draw_line;
  parent->draw_text = svg_painter_draw_text;
  parent->set_attributes_style = svg_painter_set_attributes_style;
  parent->group_start = svg_painter_group_start;
  parent->group_end = svg_painter_group_end;

  parent->bdr_pad = PADDING;
  parent->axis_pad = SPACE;
  parent->legend_pad = 0;
  parent->tick_len = TICKLENGTH;
  parent->axis_width = 5;
  parent->axis_height = 13;
  parent->title_width = 5;
  parent->title_height = 5;

  /* Open postscript file and write header to it */
  bbox[0] = (paper_width - graph_width) / 2;
  bbox[1] = (paper_height - graph_height) / 2;
  bbox[2] = (paper_width + graph_width) / 2;
  bbox[3] = (paper_height + graph_height) / 2;

  this->SVG = fopen (filename, "w");

  fprintf (this->SVG,
           "<?xml version=\"1.0\" standalone=\"no\"?>\n"
           "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20000303 Stylable//EN\"\n"
           "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");

  /* This corresponds to bounding box */
  fprintf (this->SVG,
           "<svg width=\"%.1f\" height=\"%.1f\">\n",
           DEV (graph_width), DEV (graph_height));

  /* Set initial font... */
  this->current_text_size = 11;

  return (painter_t *) this;
}
Exemple #3
0
static int
sd2gen(Chan* c, int i, Dir* dp)
{
	Qid q;
	uvlong l;
	SDpart *pp;
	SDperm *perm;
	SDunit *unit;
	SDev *sdev;
	int rv;

	sdev = sdgetdev(DEV(c->qid));
	assert(sdev);
	unit = sdev->unit[UNIT(c->qid)];

	rv = -1;
	switch(i){
	case Qctl:
		mkqid(&q, QID(DEV(c->qid), UNIT(c->qid), PART(c->qid), Qctl),
			unit->vers, QTFILE);
		perm = &unit->ctlperm;
		if(emptystr(perm->user)){
			kstrdup(&perm->user, eve);
			perm->perm = 0644;	/* nothing secret in ctl */
		}
		devdir(c, q, "ctl", 0, perm->user, perm->perm, dp);
		rv = 1;
		break;

	case Qraw:
		mkqid(&q, QID(DEV(c->qid), UNIT(c->qid), PART(c->qid), Qraw),
			unit->vers, QTFILE);
		perm = &unit->rawperm;
		if(emptystr(perm->user)){
			kstrdup(&perm->user, eve);
			perm->perm = DMEXCL|0600;
		}
		devdir(c, q, "raw", 0, perm->user, perm->perm, dp);
		rv = 1;
		break;

	case Qpart:
		pp = &unit->part[PART(c->qid)];
		l = (pp->end - pp->start) * unit->secsize;
		mkqid(&q, QID(DEV(c->qid), UNIT(c->qid), PART(c->qid), Qpart),
			unit->vers+pp->vers, QTFILE);
		if(emptystr(pp->user))
			kstrdup(&pp->user, eve);
		devdir(c, q, pp->name, l, pp->user, pp->perm, dp);
		rv = 1;
		break;
	}

	decref(&sdev->r);
	return rv;
}
Exemple #4
0
static void
svg_painter_draw_text (struct painter_t_struct *painter,
                       double x_pos, double y_pos,
                       const char *text, int just, int style)
{
  svg_painter_t *svg_painter = (svg_painter_t *) painter;
  double text_size = svg_painter->current_text_size;
  char *anchor_names[] =
    { "text-anchor=\"middle\" alignment-baseline=\"middle\"",
    "text-anchor=\"start\" alignment-baseline=\"middle\"",
    "text-anchor=\"start\" alignment-baseline=\"middle\"",
    "text-anchor=\"middle\"",
    "text-anchor=\"end\"",
    "text-anchor=\"end\"",
    "text-anchor=\"end\"",
    "text-anchor=\"middle\"",
    "text-anchor=\"start\""
  };

  // This should be more configurable...
  if (style == T_TITLE)
    text_size = 18;
  else if (style == T_AXIS)
    text_size = 11;

  if (just == T_RIGHT)
    {
      /* The following is emperical for Helvetica fonts... */
      y_pos += 0.37 * text_size;
    }
  else if (just == T_LOWERLEFT)
    {
    }
  else if (just == T_UPPERLEFT)
    {
      y_pos += 0.8 * text_size;
    }
  else if (just == T_BOTTOM)
    {
    }
  else if (just == T_TOP)
    {
      y_pos += 0.74 * text_size;
    }

  // Meanwhile do it the long and hard way...
  fprintf (svg_painter->SVG,
           "<text %s font-size=\"%f\" fill=\"RGB(%d,%d,%d)\" x=\"%f\" y=\"%f\">%s</text>\n",
           anchor_names[just],
           DEV (svg_painter->current_text_size),
           svg_painter->current_color.red / 256,
           svg_painter->current_color.green / 256,
           svg_painter->current_color.blue / 256,
           DEV (x_pos), DEV (SVGY (y_pos)), text);
}
Exemple #5
0
static int
vcongen(Chan *c, char *d, Dirtab* dir, int i, int s, Dir *dp)
{
	Proc *up = externup();
	Qid q;
	int t = TYPE(c->qid);
	int vdidx = DEV(c->qid);
	if(vdidx >= nvcon)
		error(Ebadarg);
	switch(t){
	case Qtopdir:
		if(s == DEVDOTDOT){
			q = (Qid){QID(0, Qtopdir), 0, QTDIR};
			snprint(up->genbuf, sizeof up->genbuf, "#%C", vcondevtab.dc);
			devdir(c, q, up->genbuf, 0, eve, DMDIR|0555, dp);
			return 1;
		}
		return devgen(c, nil, topdir, nelem(topdir), s, dp);
	case Qvirtcon:
		if(s == DEVDOTDOT){
			q = (Qid){QID(0, Qtopdir), 0, QTDIR};
			snprint(up->genbuf, sizeof up->genbuf, "#%C", vcondevtab.dc);
			devdir(c, q, up->genbuf, 0, eve, DMDIR|0555, dp);
			return 1;
		}
		if(s >= nvcon)
			return -1;
		snprint(up->genbuf, sizeof up->genbuf, vcons[s]->devname);
		q = (Qid) {QID(s, Qvcpipe), 0, 0};
		devdir(c, q, up->genbuf, 0, eve, 0666, dp);
		return 1;
	}
	return -1;
}
Exemple #6
0
static long
extrarw(int write, Chan *c, void *a, long n, vlong off)
{
	int i;
	SDrw *f;
	SDev *sdev;
	SDunit *unit;

	sdev = sdgetdev(DEV(c->qid));
	if(sdev == nil)
		error(Enonexist);
	if(waserror()){
		decref(&sdev->r);
		nexterror();
	}
	unit = sdev->unit[UNIT(c->qid)];
	if(unit->vers != c->qid.vers)
		error(Echange);
	unit = sdev->unit[UNIT(c->qid)];
	i = PART(c->qid);
	if(i >= unit->nefile)
		error(Enonexist);
	f = unit->efile[i].r;
	if(write)
		f = unit->efile[i].w;
	if(i >= unit->nefile || f == nil)
		error(Eperm);
	n = f(unit, c, a, n, off);
	poperror();
	decref(&sdev->r);
	return n;
}
Exemple #7
0
static int cmdq_common_init(struct nitrox_cmdq *cmdq)
{
	struct nitrox_device *ndev = cmdq->ndev;
	u32 qsize;

	qsize = (ndev->qlen) * cmdq->instr_size;
	cmdq->head_unaligned = dma_zalloc_coherent(DEV(ndev),
						   (qsize + PKT_IN_ALIGN),
						   &cmdq->dma_unaligned,
						   GFP_KERNEL);
	if (!cmdq->head_unaligned)
		return -ENOMEM;

	cmdq->head = PTR_ALIGN(cmdq->head_unaligned, PKT_IN_ALIGN);
	cmdq->dma = PTR_ALIGN(cmdq->dma_unaligned, PKT_IN_ALIGN);
	cmdq->qsize = (qsize + PKT_IN_ALIGN);

	spin_lock_init(&cmdq->response_lock);
	spin_lock_init(&cmdq->cmdq_lock);
	spin_lock_init(&cmdq->backlog_lock);

	INIT_LIST_HEAD(&cmdq->response_head);
	INIT_LIST_HEAD(&cmdq->backlog_head);
	INIT_WORK(&cmdq->backlog_qflush, backlog_qflush_work);

	atomic_set(&cmdq->pending_count, 0);
	atomic_set(&cmdq->backlog_count, 0);
	return 0;
}
Exemple #8
0
static int
sdwstat(Chan* c, uchar* dp, int n)
{
	Dir *d;
	SDpart *pp;
	SDperm *perm;
	SDunit *unit;
	SDev *sdev;

	if(c->qid.type & QTDIR)
		error(Eperm);

	sdev = sdgetdev(DEV(c->qid));
	if(sdev == nil)
		error(Enonexist);
	unit = sdev->unit[UNIT(c->qid)];
	qlock(&unit->ctl);
	d = nil;
	if(waserror()){
		free(d);
		qunlock(&unit->ctl);
		decref(&sdev->r);
		nexterror();
	}

	switch(TYPE(c->qid)){
	default:
		error(Eperm);
	case Qctl:
		perm = &unit->ctlperm;
		break;
	case Qraw:
		perm = &unit->rawperm;
		break;
	case Qpart:
		pp = &unit->part[PART(c->qid)];
		if(unit->vers+pp->vers != c->qid.vers)
			error(Enonexist);
		perm = &pp->SDperm;
		break;
	}

	if(strcmp(up->env->user, perm->user) && !iseve())
		error(Eperm);

	d = smalloc(sizeof(Dir)+n);
	n = convM2D(dp, n, &d[0], (char*)&d[1]);
	if(n == 0)
		error(Eshortstat);
	if(!emptystr(d[0].uid))
		kstrdup(&perm->user, d[0].uid);
	if(d[0].mode != ~0UL)
		perm->perm = (perm->perm & ~0777) | (d[0].mode & 0777);

	free(d);
	qunlock(&unit->ctl);
	decref(&sdev->r);
	poperror();
	return n;
}
Exemple #9
0
/*
 * Send a test message.
 *
 * Calculate number of fragments needed to send message and call send_packet
 * tot_frags number of times.
 * 
 * @param str        Message to send.
 * @param packet_id  The packet ID.
 * @param fd         Socket file descriptor.
 * @param i8_addr    Socket address structure.
 */
void send_message(char *str, uint8_t packet_id, int fd, struct sockaddr_in *i8_addr)
{
    size_t total_size;   /* Total length of message. */
    size_t pkt_size;     /* Length of payload in packet */
    int    offset;       /* Offset */
    int    frag_no;
    int    tot_frags;

    total_size = strlen(str) + 1;
    
    DEV("Fake node: Sending message (packet_id=%d, total_size=%d)",
	packet_id, total_size);
    
    tot_frags = total_size / PAYLOAD_SIZE;

    for(frag_no=0; frag_no<=tot_frags; frag_no++)
    {
	if(frag_no == tot_frags)
	    pkt_size = total_size % PAYLOAD_SIZE;
	else
	    pkt_size = PAYLOAD_SIZE;

	offset = frag_no * PAYLOAD_SIZE;
	send_packet(str,
		    pkt_size,
		    packet_id,
		    total_size,
		    offset,
		    fd,
		    i8_addr);
    }
}
Exemple #10
0
static void
add_text_fields(GtkWidget	*outer,
		t_ctxt		*ctxt)
/*
 * Add the 'name', 'description' and 'when' fields
 */
{
	GtkWidget	*table;
	t_dev		*dev;
	t_usr_ctxt	*usr;

	usr = ctxt->usr;
	dev = DEV(usr->dev_obj);

	table = gtk_table_new(2, 3, FALSE);
	gtk_table_set_row_spacings(GTK_TABLE(table), PAD);
	gtk_table_set_col_spacings(GTK_TABLE(table), PAD);
	gtk_box_pack_start(GTK_BOX(outer), table, FALSE, FALSE, PAD);

	add_label2table(table, 0, 0, "Name:", "A name for this MIDI device");
	add_label2table(table, 0, 1, "Description:", "Your own description");

	usr->fld_name = add_text2table(table, 1, 0, dev->name, TRUE);
	usr->fld_desc = add_text2table(table, 1, 1, dev->desc, TRUE);
}						 /* add_text_fields()	      */
Exemple #11
0
static void clear_pom_err_intr(struct nitrox_device *ndev)
{
	u64 value;

	value = nitrox_read_csr(ndev, POM_INT);
	nitrox_write_csr(ndev, POM_INT, value);
	dev_err_ratelimited(DEV(ndev), "POM_INT  0x%016llx\n", value);
}
Exemple #12
0
static void clear_lbc_err_intr(struct nitrox_device *ndev)
{
	union lbc_int lbc_int;
	u64 value, offset;
	int i;

	lbc_int.value = nitrox_read_csr(ndev, LBC_INT);
	dev_err_ratelimited(DEV(ndev), "LBC_INT  0x%016llx\n", lbc_int.value);

	if (lbc_int.s.dma_rd_err) {
		for (i = 0; i < NR_CLUSTERS; i++) {
			offset = EFL_CORE_VF_ERR_INT0X(i);
			value = nitrox_read_csr(ndev, offset);
			nitrox_write_csr(ndev, offset, value);
			offset = EFL_CORE_VF_ERR_INT1X(i);
			value = nitrox_read_csr(ndev, offset);
			nitrox_write_csr(ndev, offset, value);
		}
	}

	if (lbc_int.s.cam_soft_err) {
		dev_err_ratelimited(DEV(ndev), "CAM_SOFT_ERR, invalidating LBC\n");
		invalidate_lbc(ndev);
	}

	if (lbc_int.s.pref_dat_len_mismatch_err) {
		offset = LBC_PLM_VF1_64_INT;
		value = nitrox_read_csr(ndev, offset);
		nitrox_write_csr(ndev, offset, value);
		offset = LBC_PLM_VF65_128_INT;
		value = nitrox_read_csr(ndev, offset);
		nitrox_write_csr(ndev, offset, value);
	}

	if (lbc_int.s.rd_dat_len_mismatch_err) {
		offset = LBC_ELM_VF1_64_INT;
		value = nitrox_read_csr(ndev, offset);
		nitrox_write_csr(ndev, offset, value);
		offset = LBC_ELM_VF65_128_INT;
		value = nitrox_read_csr(ndev, offset);
		nitrox_write_csr(ndev, offset, value);
	}
	nitrox_write_csr(ndev, LBC_INT, lbc_int.value);
}
Exemple #13
0
static void clear_nps_core_err_intr(struct nitrox_device *ndev)
{
	u64 value;

	/* Write 1 to clear */
	value = nitrox_read_csr(ndev, NPS_CORE_INT);
	nitrox_write_csr(ndev, NPS_CORE_INT, value);

	dev_err_ratelimited(DEV(ndev), "NSP_CORE_INT  0x%016llx\n", value);
}
Exemple #14
0
static void clear_nps_pkt_err_intr(struct nitrox_device *ndev)
{
	union nps_pkt_int pkt_int;
	unsigned long value, offset;
	int i;

	pkt_int.value = nitrox_read_csr(ndev, NPS_PKT_INT);
	dev_err_ratelimited(DEV(ndev), "NPS_PKT_INT  0x%016llx\n",
			    pkt_int.value);

	if (pkt_int.s.slc_err) {
		offset = NPS_PKT_SLC_ERR_TYPE;
		value = nitrox_read_csr(ndev, offset);
		nitrox_write_csr(ndev, offset, value);
		dev_err_ratelimited(DEV(ndev),
				    "NPS_PKT_SLC_ERR_TYPE  0x%016lx\n", value);

		offset = NPS_PKT_SLC_RERR_LO;
		value = nitrox_read_csr(ndev, offset);
		nitrox_write_csr(ndev, offset, value);
		/* enable the solicit ports */
		for_each_set_bit(i, &value, BITS_PER_LONG)
			enable_pkt_solicit_port(ndev, i);

		dev_err_ratelimited(DEV(ndev),
				    "NPS_PKT_SLC_RERR_LO  0x%016lx\n", value);

		offset = NPS_PKT_SLC_RERR_HI;
		value = nitrox_read_csr(ndev, offset);
		nitrox_write_csr(ndev, offset, value);
		dev_err_ratelimited(DEV(ndev),
				    "NPS_PKT_SLC_RERR_HI  0x%016lx\n", value);
	}

	if (pkt_int.s.in_err) {
		offset = NPS_PKT_IN_ERR_TYPE;
		value = nitrox_read_csr(ndev, offset);
		nitrox_write_csr(ndev, offset, value);
		dev_err_ratelimited(DEV(ndev),
				    "NPS_PKT_IN_ERR_TYPE  0x%016lx\n", value);
		offset = NPS_PKT_IN_RERR_LO;
		value = nitrox_read_csr(ndev, offset);
		nitrox_write_csr(ndev, offset, value);
		/* enable the input ring */
		for_each_set_bit(i, &value, BITS_PER_LONG)
			enable_pkt_input_ring(ndev, i);

		dev_err_ratelimited(DEV(ndev),
				    "NPS_PKT_IN_RERR_LO  0x%016lx\n", value);

		offset = NPS_PKT_IN_RERR_HI;
		value = nitrox_read_csr(ndev, offset);
		nitrox_write_csr(ndev, offset, value);
		dev_err_ratelimited(DEV(ndev),
				    "NPS_PKT_IN_RERR_HI  0x%016lx\n", value);
	}
}
Exemple #15
0
static int create_crypto_dma_pool(struct nitrox_device *ndev)
{
	size_t size;

	/* Crypto context pool, 16 byte aligned */
	size = CRYPTO_CTX_SIZE + sizeof(struct ctx_hdr);
	ndev->ctx_pool = dma_pool_create("crypto-context",
					 DEV(ndev), size, 16, 0);
	if (!ndev->ctx_pool)
		return -ENOMEM;

	return 0;
}
Exemple #16
0
static Chan*
vconopen(Chan *c, int omode)
{
	uint t = TYPE(c->qid);
	uint vdidx = DEV(c->qid);
	if(vdidx >= nvcon)
		error(Ebadarg);
	c = devopen(c, omode, (Dirtab*)0, 0, vcongen);
	switch(t) {
	default:
		break;
	}
	return c;
}
Exemple #17
0
static int32_t
vconread(Chan *c, void *va, int32_t n, int64_t offset)
{
	int vdidx = DEV(c->qid);
	if(vdidx >= nvcon)
		error(Ebadarg);
	switch(TYPE(c->qid)) {
	case Qtopdir:
	case Qvirtcon:
		return devdirread(c, va, n, (Dirtab *)0, 0L, vcongen);
	case Qvcpipe:
		return rwcommon(vcons[vdidx], va, n, 0);
	}
	return -1;
}
Exemple #18
0
void
edit_dev(	t_obj	*dev_obj)		 /* The Device to edit	      */
{
	t_ctxt		*ctxt;			 /* The context		      */

	ctxt = new_ctxt(0, sizeof(t_usr_ctxt), dev_obj);

	if(!ctxt)
		return;

	USR(ctxt)->dev_obj = dev_obj;		 /* Store channel in context  */
	USR(ctxt)->dev = DEV(dev_obj);		 /* & the structure itself    */

	init_window(ctxt);
}						 /* edit_dev()		      */
Exemple #19
0
static Chan*
sdopen(Chan* c, int omode)
{
	SDpart *pp;
	SDunit *unit;
	SDev *sdev;
	uchar tp;

	c = devopen(c, omode, 0, 0, sdgen);
	if((tp = TYPE(c->qid)) != Qctl && tp != Qraw && tp != Qpart)
		return c;

	sdev = sdgetdev(DEV(c->qid));
	if(sdev == nil)
		error(Enonexist);

	unit = sdev->unit[UNIT(c->qid)];

	switch(TYPE(c->qid)){
	case Qctl:
		c->qid.vers = unit->vers;
		break;
	case Qraw:
		c->qid.vers = unit->vers;
		if(tas(&unit->rawinuse) != 0){
			c->flag &= ~COPEN;
			decref(&sdev->r);
			error(Einuse);
		}
		unit->state = Rawcmd;
		break;
	case Qpart:
		qlock(&unit->ctl);
		if(waserror()){
			qunlock(&unit->ctl);
			c->flag &= ~COPEN;
			decref(&sdev->r);
			nexterror();
		}
		pp = &unit->part[PART(c->qid)];
		c->qid.vers = unit->vers+pp->vers;
		qunlock(&unit->ctl);
		poperror();
		break;
	}
	decref(&sdev->r);
	return c;
}
Exemple #20
0
static int32_t
vconwrite(Chan *c, void *va, int32_t n, int64_t offset)
{
	int vdidx = DEV(c->qid);
	if(vdidx >= nvcon)
		error(Ebadarg);
	switch(TYPE(c->qid)) {
	case Qtopdir:
	case Qvirtcon:
		error(Eperm);
		return -1;
	case Qvcpipe:
		return rwcommon(vcons[vdidx], va, n, 1);
	}
	return -1;
}
Exemple #21
0
static void cmdq_common_cleanup(struct nitrox_cmdq *cmdq)
{
	struct nitrox_device *ndev = cmdq->ndev;

	cancel_work_sync(&cmdq->backlog_qflush);

	dma_free_coherent(DEV(ndev), cmdq->qsize,
			  cmdq->head_unaligned, cmdq->dma_unaligned);

	atomic_set(&cmdq->pending_count, 0);
	atomic_set(&cmdq->backlog_count, 0);

	cmdq->dbell_csr_addr = NULL;
	cmdq->head = NULL;
	cmdq->dma = 0;
	cmdq->qsize = 0;
	cmdq->instr_size = 0;
}
Exemple #22
0
static int
efilegen(Chan *c, SDunit *unit, int i, Dir *dp)
{
	Qid q;
	SDfile *e;

	i -= SDnpart;
	if(unit->nefile == 0 || i >= unit->nefile)
		return -1;
	if(i < 0)
		return 0;
	e = unit->efile + i;
	if(emptystr(e->user))
		kstrdup(&e->user, eve);
	mkqid(&q, QID(DEV(c->qid), UNIT(c->qid), i, Qextra),
		unit->vers, QTFILE);
	devdir(c, q, e->name, 0, e->user, e->perm, dp);
	return 1;
}
Exemple #23
0
static void
svg_painter_draw_marks (painter_t * painter, GArray * marks_array)
{
  svg_painter_t *svg_painter = (svg_painter_t *) painter;
  mark_t *marks = (mark_t *) marks_array->data;
  FILE *SVG = svg_painter->SVG; /* Shortcut */
  int m_idx;
  int mark_type = svg_painter->current_mark_type;
  int rr = svg_painter->current_color.red / 256;
  int gg = svg_painter->current_color.green / 256;
  int bb = svg_painter->current_color.blue / 256;

  /* TBD: Compact this by defining the style once for each set of
     points! */
  for (m_idx = 0; m_idx < marks_array->len; m_idx++)
    {
      double x = marks[m_idx].x;
      double y = SVGY (marks[m_idx].y);

      /* Define postscript for the current mark */
      if (mark_type == MARK_TYPE_FCIRCLE)
        {
          fprintf (SVG,
                   "<circle cx=\"%f\" cy=\"%f\" r=\"%f\" fill=\"rgb(%d,%d,%d)\"/>\n",
                   DEV (x), DEV (y),
                   DEV (svg_painter->current_mark_size_x / 2), rr, gg, bb);
        }
      else if (mark_type == MARK_TYPE_CIRCLE)
        {
          fprintf (SVG,
                   "<circle cx=\"%f\" cy=\"%f\" r=\"%f\" stroke=\"rgb(%d,%d,%d)\"/> stroke_width=\"%f\"\n",
                   DEV (x), DEV (y),
                   DEV (svg_painter->current_mark_size_x / 2), rr, gg, bb,
                   1.0 * DEV (svg_painter->current_line_width));
        }
      /* TBD! */
#if 0
      else if (mark_type == MARK_TYPE_SQUARE)
        fprintf (SVG, "");
      else if (mark_type == MARK_TYPE_FSQUARE)
        fprintf (SVG, "");
#endif
    }

}
Exemple #24
0
/*
 * Creates a test socket (UDP in this case) and simulate nodes sending
 * packets to i8-transeiver.
 */
void *packet_generator(void *arg)
{
    struct sockaddr_in i8_addr;

    int i8_fd;
    int ret;

    int packet_id = 0;

    /* Create socket */
    i8_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if(i8_fd < 0)
    {
	ERR("Fake node: Failed to create socket.");
    }

    /* Setup socket */
    memset(&i8_addr, 0, sizeof(struct sockaddr_in));
    i8_addr.sin_family = AF_INET;
    i8_addr.sin_port = htons(TEST_PORT);
    ret = inet_aton(TEST_SERVER, &i8_addr.sin_addr);
    if(ret < 0)
    {
	ERR("Fake node: Failed to setup socket.");
    }

    sleep(1);

    packet_id = 0;
    while(running)
    {
	send_message(msg, packet_id, i8_fd, &i8_addr);
	packet_id++;
	sleep(5);
    }

    close(i8_fd);

    DEV("Fake node: Thread exiting");

    pthread_exit(NULL);
}
Exemple #25
0
static void clear_efl_err_intr(struct nitrox_device *ndev)
{
	int i;

	for (i = 0; i < NR_CLUSTERS; i++) {
		union efl_core_int core_int;
		u64 value, offset;

		offset = EFL_CORE_INTX(i);
		core_int.value = nitrox_read_csr(ndev, offset);
		nitrox_write_csr(ndev, offset, core_int.value);
		dev_err_ratelimited(DEV(ndev), "ELF_CORE(%d)_INT  0x%016llx\n",
				    i, core_int.value);
		if (core_int.s.se_err) {
			offset = EFL_CORE_SE_ERR_INTX(i);
			value = nitrox_read_csr(ndev, offset);
			nitrox_write_csr(ndev, offset, value);
		}
	}
}
Exemple #26
0
static int nitrox_sriov_disable(struct pci_dev *pdev)
{
	struct nitrox_device *ndev = pci_get_drvdata(pdev);

	if (!test_bit(__NDEV_SRIOV_BIT, &ndev->flags))
		return 0;

	if (pci_vfs_assigned(pdev)) {
		dev_warn(DEV(ndev), "VFs are attached to VM. Can't disable SR-IOV\n");
		return -EPERM;
	}
	pci_disable_sriov(pdev);
	/* clear bit in flags */
	clear_bit(__NDEV_SRIOV_BIT, &ndev->flags);

	ndev->num_vfs = 0;
	ndev->mode = __NDEV_MODE_PF;

	config_nps_core_vfcfg_mode(ndev, ndev->mode);

	return pf_sriov_init(ndev);
}
Exemple #27
0
static void
sdclose(Chan* c)
{
	SDunit *unit;
	SDev *sdev;

	if(c->qid.type & QTDIR)
		return;
	if(!(c->flag & COPEN))
		return;

	switch(TYPE(c->qid)){
	default:
		break;
	case Qraw:
		sdev = sdgetdev(DEV(c->qid));
		if(sdev){
			unit = sdev->unit[UNIT(c->qid)];
			unit->rawinuse = 0;
			decref(&sdev->r);
		}
		break;
	}
}
Exemple #28
0
static void
svg_painter_draw_segments (painter_t * painter, GArray * segments)
{
  svg_painter_t *svg_painter = (svg_painter_t *) painter;
  seg_t *segs = (seg_t *) segments->data;
  int seg_idx;

  fprintf (svg_painter->SVG,
           "<g style=\"stroke:#%02x%02x%02x;stroke-width:%f;fill:none\">\n",
           svg_painter->current_color.red / 256,
           svg_painter->current_color.green / 256,
           svg_painter->current_color.blue / 256,
           1.0 * DEV (svg_painter->current_line_width));

  fprintf (svg_painter->SVG, "<path d=\"");
  for (seg_idx = 0; seg_idx < segments->len; seg_idx++)
    {
      if (seg_idx == 0)
        {
          fprintf (svg_painter->SVG, "M %f,%f ",
                   DEV (segs[seg_idx].x1), DEV (SVGY (segs[seg_idx].y1)));
        }
      else if ((segs[seg_idx].x1 != segs[seg_idx - 1].x2) ||
               (segs[seg_idx].y1 != segs[seg_idx - 1].y2))
        {
          // Close polyline and open a new one
          fprintf (svg_painter->SVG,
                   "M %f,%f ",
                   DEV (segs[seg_idx].x1), DEV (SVGY (segs[seg_idx].y1)));
        }
      fprintf (svg_painter->SVG,
               "L %f,%f ", DEV (segs[seg_idx].x2),
               DEV (SVGY (segs[seg_idx].y2)));
    }
  fprintf (svg_painter->SVG, "\"/>\n</g>\n");
}
/* netwinder host-specific stuff */
static int __init netwinder_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
{
#define DEV(v,d) ((v)<<16|(d))
	switch (DEV(dev->vendor, dev->device)) {
	case DEV(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142):
	case DEV(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C885):
	case DEV(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_YELLOWFIN):
		return IRQ_NETWINDER_ETHER100;

	case DEV(PCI_VENDOR_ID_WINBOND2, 0x5a5a):
		return IRQ_NETWINDER_ETHER10;

	case DEV(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_83C553):
		return 0;

	case DEV(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105):
		return IRQ_ISA_HARDDISK1;

	case DEV(PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_2000):
	case DEV(PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_2010):
	case DEV(PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_5000):
		return IRQ_NETWINDER_VGA;

	case DEV(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21285):
		return 0;

	default:
		printk(KERN_ERR "PCI: %02X:%02X [%04X:%04X] unknown device\n",
			dev->bus->number, dev->devfn,
			dev->vendor, dev->device);
		return 0;
	}
}
Exemple #30
0
    bool PipelineCommand::executePipeline(
        BSONObjBuilder &result, string &errmsg, const string &ns,
        intrusive_ptr<Pipeline> &pPipeline,
        intrusive_ptr<DocumentSourceCursor> &pSource,
        intrusive_ptr<ExpressionContext> &pCtx) {

        /* this is the normal non-debug path */
        if (!pPipeline->getSplitMongodPipeline())
            return pPipeline->run(result, errmsg, pSource);

        /* setup as if we're in the router */
        pCtx->setInRouter(true);

        /*
          Here, we'll split the pipeline in the same way we would for sharding,
          for testing purposes.

          Run the shard pipeline first, then feed the results into the remains
          of the existing pipeline.

          Start by splitting the pipeline.
         */
        intrusive_ptr<Pipeline> pShardSplit(
            pPipeline->splitForSharded());

        /*
          Write the split pipeline as we would in order to transmit it to
          the shard servers.
        */
        BSONObjBuilder shardBuilder;
        pShardSplit->toBson(&shardBuilder);
        BSONObj shardBson(shardBuilder.done());

        DEV (log() << "\n---- shardBson\n" <<
             shardBson.jsonString(Strict, 1) << "\n----\n").flush();

        /* for debugging purposes, show what the pipeline now looks like */
        DEV {
            BSONObjBuilder pipelineBuilder;
            pPipeline->toBson(&pipelineBuilder);
            BSONObj pipelineBson(pipelineBuilder.done());
            (log() << "\n---- pipelineBson\n" <<
             pipelineBson.jsonString(Strict, 1) << "\n----\n").flush();
        }

        /* on the shard servers, create the local pipeline */
        intrusive_ptr<ExpressionContext> pShardCtx(
            ExpressionContext::create(&InterruptStatusMongod::status));
        intrusive_ptr<Pipeline> pShardPipeline(
            Pipeline::parseCommand(errmsg, shardBson, pShardCtx));
        if (!pShardPipeline.get()) {
            return false;
        }

        /* run the shard pipeline */
        BSONObjBuilder shardResultBuilder;
        string shardErrmsg;
        pShardPipeline->run(shardResultBuilder, shardErrmsg, pSource);
        BSONObj shardResult(shardResultBuilder.done());

        /* pick out the shard result, and prepare to read it */
        intrusive_ptr<DocumentSourceBsonArray> pShardSource;
        BSONObjIterator shardIter(shardResult);
        while(shardIter.more()) {
            BSONElement shardElement(shardIter.next());
            const char *pFieldName = shardElement.fieldName();

            if ((strcmp(pFieldName, "result") == 0) ||
                (strcmp(pFieldName, "serverPipeline") == 0)) {
                pShardSource = DocumentSourceBsonArray::create(
                    &shardElement, pCtx);

                /*
                  Connect the output of the shard pipeline with the mongos
                  pipeline that will merge the results.
                */
                return pPipeline->run(result, errmsg, pShardSource);
            }
        }

        /* NOTREACHED */
        verify(false);
        return false;
    }