예제 #1
0
파일: rxe.c 프로젝트: Anjali05/linux
/* initialize port state, note IB convention that HCA ports are always
 * numbered from 1
 */
static int rxe_init_ports(struct rxe_dev *rxe)
{
	struct rxe_port *port = &rxe->port;

	rxe_init_port_param(port);

	if (!port->attr.pkey_tbl_len || !port->attr.gid_tbl_len)
		return -EINVAL;

	port->pkey_tbl = kcalloc(port->attr.pkey_tbl_len,
			sizeof(*port->pkey_tbl), GFP_KERNEL);

	if (!port->pkey_tbl)
		return -ENOMEM;

	port->pkey_tbl[0] = 0xffff;
	addrconf_addr_eui48((unsigned char *)&port->port_guid,
			    rxe->ndev->dev_addr);

	spin_lock_init(&port->port_lock);

	return 0;
}
예제 #2
0
파일: rxe.c 프로젝트: Tyler-D/RXE
/* initialize port state, note IB convention
   that HCA ports are always numbered from 1 */
static int rxe_init_ports(struct rxe_dev *rxe)
{
	int err;
	unsigned int port_num;
	struct rxe_port *port;

	rxe->port = kcalloc(rxe->num_ports, sizeof(struct rxe_port),
			    GFP_KERNEL);
	if (!rxe->port)
		return -ENOMEM;

	for (port_num = 1; port_num <= rxe->num_ports; port_num++) {
		port = &rxe->port[port_num - 1];

		rxe_init_port_param(rxe, port_num);

		if (!port->attr.pkey_tbl_len) {
			err = -EINVAL;
			goto err1;
		}

		port->pkey_tbl = kcalloc(port->attr.pkey_tbl_len,
					 sizeof(*port->pkey_tbl), GFP_KERNEL);
		if (!port->pkey_tbl) {
			err = -ENOMEM;
			goto err1;
		}

		port->pkey_tbl[0] = 0xffff;

		if (!port->attr.gid_tbl_len) {
			kfree(port->pkey_tbl);
			err = -EINVAL;
			goto err1;
		}

		port->guid_tbl = kcalloc(port->attr.gid_tbl_len,
					 sizeof(*port->guid_tbl), GFP_KERNEL);
		if (!port->guid_tbl) {
			kfree(port->pkey_tbl);
			err = -ENOMEM;
			goto err1;
		}

		port->guid_tbl[0] = rxe->ifc_ops->port_guid(rxe, port_num);

		spin_lock_init(&port->port_lock);
	}

	return 0;

err1:
	while (--port_num >= 1) {
		port = &rxe->port[port_num - 1];
		kfree(port->pkey_tbl);
		kfree(port->guid_tbl);
	}

	kfree(rxe->port);
	return err;
}