ixgbe_caller.c 60.7 KB
Newer Older
1 2 3 4 5 6 7 8
#include <lcd_config/pre_hook.h>

#include <libcap.h>
#include <liblcd/liblcd.h>
#include <liblcd/sync_ipc_poll.h>
#include <liblcd/glue_cspace.h>
#include "../../ixgbe_common.h"
#include "../ixgbe_caller.h"
9
#include <asm/lcd_domains/liblcd.h>
10 11

#include <liblcd/netdev_helper.h>
12 13 14 15
#include <lcd_config/post_hook.h>

struct cptr sync_ep;
static struct glue_cspace *c_cspace;
16
extern struct glue_cspace *ixgbe_cspace;
17 18 19 20
extern struct thc_channel *ixgbe_async;
extern cptr_t ixgbe_sync_endpoint;
extern cptr_t ixgbe_register_channel;

21 22
static struct net_device *g_net_device;

23 24 25 26 27 28 29 30 31 32 33 34 35
int glue_ixgbe_init(void)
{
	int ret;
	ret = glue_cap_init();
	if (ret) {
		LIBLCD_ERR("cap init");
		goto fail1;
	}
	ret = glue_cap_create(&c_cspace);
	if (ret) {
		LIBLCD_ERR("cap create");
		goto fail2;
	}
36
	ixgbe_cspace = c_cspace;
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
	return 0;
fail2:
	glue_cap_exit();
fail1:
	return ret;

}

void glue_ixgbe_exit(void)
{
	glue_cap_destroy(c_cspace);
	glue_cap_exit();

}

static int setup_async_channel(cptr_t *buf1_cptr_out, cptr_t *buf2_cptr_out,
			struct thc_channel **chnl_out)
{
	int ret;
	cptr_t buf1_cptr, buf2_cptr;
	gva_t buf1_addr, buf2_addr;
	struct fipc_ring_channel *fchnl;
	struct thc_channel *chnl;
	unsigned int pg_order = ASYNC_RPC_BUFFER_ORDER - PAGE_SHIFT;
	LIBLCD_MSG("%s\n",__func__);
	/*
	 * Allocate buffers
	 *
	 * (We use the lower level alloc. If we used the heap, even though
	 * we may alloc only 1 - 2 pages, we would end up sharing around
	 * 4 MB chunks of memory, since the heap uses coarse microkernel
	 * allocations.)
	 */
	ret = _lcd_alloc_pages(GFP_KERNEL, pg_order, &buf1_cptr);
	if (ret) {
		LIBLCD_ERR("buf1 alloc");
		goto fail1;
	}
	ret = _lcd_alloc_pages(GFP_KERNEL, pg_order, &buf2_cptr);
	if (ret) {
		LIBLCD_ERR("buf2 alloc");
		goto fail2;
	}
	/*
	 * Map them somewhere
	 */
	ret = lcd_map_virt(buf1_cptr, pg_order, &buf1_addr);
	if (ret) {
		LIBLCD_ERR("error mapping buf1");
		goto fail3;
	}
	ret = lcd_map_virt(buf2_cptr, pg_order, &buf2_addr);
	if (ret) {
		LIBLCD_ERR("error mapping buf2");
		goto fail4;
	}
	/*
	 * Prep buffers for rpc
	 */
	ret = fipc_prep_buffers(ASYNC_RPC_BUFFER_ORDER,
				(void *)gva_val(buf1_addr),
				(void *)gva_val(buf2_addr));
	if (ret) {
		LIBLCD_ERR("prep buffers");
		goto fail5;
	}
	LIBLCD_MSG("==> Prep buffers");
	/*
	 * Alloc and init channel header
	 */
	fchnl = kmalloc(sizeof(*fchnl), GFP_KERNEL);
	if (!fchnl) {
		ret = -ENOMEM;
		LIBLCD_ERR("chnl alloc");
		goto fail6;
	}
	ret = fipc_ring_channel_init(fchnl, ASYNC_RPC_BUFFER_ORDER,
				(void *)gva_val(buf1_addr),
				(void *)gva_val(buf2_addr));
	if (ret) {
		LIBLCD_ERR("ring chnl init");
		goto fail7;
	}
	/*
	 * Install async channel in async dispatch loop
	 */
	chnl = kzalloc(sizeof(*chnl), GFP_KERNEL);
	if (!chnl) {
		ret = -ENOMEM;
		LIBLCD_ERR("alloc failed");
		goto fail8;
	}
	ret = thc_channel_init(chnl, fchnl);
	if (ret) {
		LIBLCD_ERR("error init'ing async channel group item");
		goto fail9;
	}

	*buf1_cptr_out = buf1_cptr;
	*buf2_cptr_out = buf2_cptr;
	*chnl_out = chnl;

	LIBLCD_MSG("Returning from %s", __func__);
	return 0;

fail9:
	kfree(chnl);
fail8:
fail7:
	kfree(fchnl);
fail6:
fail5:
	lcd_unmap_virt(buf1_addr, pg_order);
fail4:
	lcd_unmap_virt(buf1_addr, pg_order);
fail3:
	lcd_cap_delete(buf2_cptr);
fail2:
	lcd_cap_delete(buf1_cptr);
fail1:
	return ret;
}

static void destroy_async_channel(struct thc_channel *chnl)
{
	unsigned int pg_order = ASYNC_RPC_BUFFER_ORDER - PAGE_SHIFT;
	gva_t tx_gva, rx_gva;
	cptr_t tx, rx;
	int ret;
	unsigned long unused1, unused2;
	/*
	 * Translate ring buffers to cptrs
	 */
	tx_gva = __gva((unsigned long)thc_channel_to_fipc(chnl)->tx.buffer);
	rx_gva = __gva((unsigned long)thc_channel_to_fipc(chnl)->rx.buffer);
	ret = lcd_virt_to_cptr(tx_gva, &tx, &unused1, &unused2);
	if (ret) {
		LIBLCD_ERR("failed to translate tx to cptr");
		goto fail1;
	}
	ret = lcd_virt_to_cptr(rx_gva, &rx, &unused1, &unused2);
	if (ret) {
		LIBLCD_ERR("failed to translate rx to cptr");
		goto fail2;
	}
	/*
	 * Unmap and kill tx/rx
	 */
	lcd_unmap_virt(tx_gva, pg_order);
	lcd_cap_delete(tx);
	lcd_unmap_virt(rx_gva, pg_order);
	lcd_cap_delete(rx);
	/*
	 * Free chnl header
	 */
	kfree(thc_channel_to_fipc(chnl));
	/*
	 * Free the async channel
	 *
	 * XXX: This is ok to do because there is no dispatch loop
	 * polling on the channel when we free it.
	 */
	kfree(chnl);

	return;

fail2:
fail1:
	return;
}

int create_async_channel(void)
{
	int ret;
	cptr_t tx, rx;
	struct thc_channel *chnl;
	/*
	 * Set up async and sync channels
	 */
	ret = lcd_create_sync_endpoint(&ixgbe_sync_endpoint);
	if (ret) {
		LIBLCD_ERR("lcd_create_sync_endpoint");
		goto fail1;
	}
	ret = setup_async_channel(&tx, &rx, &chnl);
	if (ret) {
		LIBLCD_ERR("async chnl setup failed");
		goto fail2;
	}
        lcd_set_cr0(ixgbe_sync_endpoint);
        lcd_set_cr1(rx);
        lcd_set_cr2(tx);

	LIBLCD_MSG("sync call %s", __func__);
	ret = lcd_sync_call(ixgbe_register_channel);

	LIBLCD_MSG("sync call returned%s", __func__);

        /*
         * Flush cap registers
         */
        lcd_set_cr0(CAP_CPTR_NULL);
        lcd_set_cr1(CAP_CPTR_NULL);
        lcd_set_cr2(CAP_CPTR_NULL);
        if (ret) {
                LIBLCD_ERR("lcd_call");
                goto fail3;
        }
	ixgbe_async = chnl;
	LIBLCD_MSG("%s returns", __func__);
	return ret;
fail3:
        destroy_async_channel(chnl);
fail2:
	lcd_cap_delete(ixgbe_sync_endpoint);
fail1:
	return ret;
}

256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
void pci_disable_msix(struct pci_dev *dev)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_DISABLE_MSIX);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return;
fail_async:
fail_ipc:
	return;
}

int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int minvec, int maxvec)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	int sync_ret;
	unsigned 	long p_mem_sz;
	unsigned 	long p_offset;
	cptr_t p_cptr;
	unsigned 	int request_cookie;

	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}

	async_msg_set_fn_type(_request,
			PCI_ENABLE_MSIX_RANGE);

	fipc_set_reg0(_request, minvec);
	fipc_set_reg1(_request, maxvec);

	sync_ret = lcd_virt_to_cptr(__gva(( unsigned  long )entries),
		&p_cptr,
		&p_mem_sz,
		&p_offset);
	if (sync_ret) {
		LIBLCD_ERR("virt to cptr failed");
		lcd_exit(-1);
	}
	ret = thc_ipc_send_request(ixgbe_async,
		_request,
		&request_cookie);
	if (ret) {
		LIBLCD_ERR("thc_ipc_send_request");
		goto fail_ipc;
	}
	lcd_set_r0(ilog2(( p_mem_sz ) >> ( PAGE_SHIFT )));
	lcd_set_r1(p_offset);
	lcd_set_cr0(p_cptr);
	sync_ret = lcd_sync_send(ixgbe_sync_endpoint);
	lcd_set_cr0(CAP_CPTR_NULL);
	if (sync_ret) {
		LIBLCD_ERR("failed to send");
		lcd_exit(-1);
	}

	ret = thc_ipc_recv_response(ixgbe_async,
		request_cookie,
		&_response);

	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}

	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;


}

354 355 356 357 358 359 360 361 362 363
int __must_check __pci_register_driver(struct pci_driver *drv,
		struct module *owner,
		const char* name)
{
	struct pci_driver_container *drv_container;
	struct module_container *owner_container;
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
364

365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
	drv_container = container_of(drv,
		struct pci_driver_container,
		pci_driver);
	ret = glue_cap_insert_pci_driver_type(c_cspace,
		drv_container,
		&drv_container->my_ref);
	if (ret) {
		LIBLCD_ERR("lcd insert");
		goto fail_insert;
	}
	owner_container = container_of(owner,
		struct module_container,
		module);
	ret = glue_cap_insert_module_type(c_cspace,
		owner_container,
		&owner_container->my_ref);
	if (ret) {
		LIBLCD_ERR("lcd insert");
		goto fail_insert;
	}
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			__PCI_REGISTER_DRIVER);
	fipc_set_reg2(_request,
			drv_container->my_ref.cptr);
	fipc_set_reg3(_request,
			owner_container->my_ref.cptr);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
404 405
	drv_container->other_ref.cptr = fipc_get_reg1(_response);
	owner_container->other_ref.cptr = fipc_get_reg2(_response);
406 407 408 409 410 411 412 413 414 415 416
	drv_container->pci_driver.driver.owner = &owner_container->module;
	func_ret = fipc_get_reg3(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_insert:
fail_ipc:
	return ret;
}

417 418 419 420 421 422 423 424 425
struct net_device *alloc_etherdev_mqs(int sizeof_priv,
		unsigned int txqs,
		unsigned int rxqs)
{
	struct net_device_container *func_ret_container;
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	struct net_device *func_ret;
426 427
	struct net_device *dev;

428 429 430 431 432 433 434 435 436 437 438 439 440
	unsigned int alloc_size = sizeof(struct net_device_container);
	void *p;

	if (sizeof_priv) {
		/* ensure 32-byte alignment of private area */
		alloc_size = ALIGN(alloc_size, NETDEV_ALIGN);
		alloc_size += sizeof_priv;
	}
	/* ensure 32-byte alignment of whole construct */
	alloc_size += NETDEV_ALIGN - 1;

	p = kzalloc(alloc_size, GFP_KERNEL);
	if (!p) {
441 442 443
		LIBLCD_ERR("kzalloc");
		goto fail_alloc;
	}
444
	func_ret_container = PTR_ALIGN(p, NETDEV_ALIGN);
445
	dev = func_ret = &func_ret_container->net_device;
446

447 448
	/* assign global instance */
	g_net_device = func_ret;
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
	ret = glue_cap_insert_net_device_type(c_cspace,
		func_ret_container,
		&func_ret_container->my_ref);
	if (ret) {
		LIBLCD_ERR("lcd insert");
		goto fail_insert;
	}
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			ALLOC_ETHERDEV_MQS);
	fipc_set_reg1(_request,
			sizeof_priv);
	fipc_set_reg2(_request,
			txqs);
	fipc_set_reg3(_request,
			rxqs);
	fipc_set_reg4(_request,
			func_ret_container->my_ref.cptr);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret_container->other_ref.cptr = fipc_get_reg1(_response);
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503

	dev_addr_init(dev);

	dev_mc_init(dev);
	dev_uc_init(dev);

	dev->gso_max_size = GSO_MAX_SIZE;
	dev->gso_max_segs = GSO_MAX_SEGS;

	INIT_LIST_HEAD(&dev->napi_list);
	INIT_LIST_HEAD(&dev->unreg_list);
	INIT_LIST_HEAD(&dev->close_list);
	INIT_LIST_HEAD(&dev->link_watch_list);
	INIT_LIST_HEAD(&dev->adj_list.upper);
	INIT_LIST_HEAD(&dev->adj_list.lower);
	INIT_LIST_HEAD(&dev->all_adj_list.upper);
	INIT_LIST_HEAD(&dev->all_adj_list.lower);
	INIT_LIST_HEAD(&dev->ptype_all);
	INIT_LIST_HEAD(&dev->ptype_specific);
	dev->priv_flags = IFF_XMIT_DST_RELEASE | IFF_XMIT_DST_RELEASE_PERM;
	dev->num_tx_queues = txqs;
	dev->real_num_tx_queues = txqs;

	netif_alloc_netdev_queues(dev);
504 505 506 507 508

	if (!func_ret->dev_addr) {
		LIBLCD_ERR("dev_addr assignment failed");
	}

509 510 511 512 513 514 515 516 517 518
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_insert:
fail_alloc:
fail_ipc:
	return NULL;
}

519 520
/* FIXME: Handle this without extern */
extern struct pci_driver_container ixgbe_driver_container;
521
u64 dma_mask = 0;
522 523 524 525 526 527

int probe_callee(struct fipc_message *_request,
		struct thc_channel *_channel,
		struct glue_cspace *cspace,
		struct cptr sync_ep)
{
528
	struct pci_dev_container *dev_container;
529 530 531
	struct fipc_message *_response;
	unsigned 	int request_cookie;
	int func_ret;
532
	int ret = 0;
533 534
	cptr_t other_ref;

535 536 537 538 539 540
#ifdef PCI_REGIONS
	cptr_t res0_cptr;
	gpa_t gpa_addr;
	unsigned int res0_len;
	void *dev_resource_0;
#endif
541

542
	LIBLCD_MSG("%s called", __func__);
543
	request_cookie = thc_get_request_cookie(_request);
544 545
	dma_mask = fipc_get_reg2(_request);
	other_ref.cptr = fipc_get_reg1(_request);
546

547 548 549
	fipc_recv_msg_end(thc_channel_to_fipc(_channel),
			_request);

550 551 552 553 554 555 556 557 558 559 560 561 562
	dev_container = kzalloc(sizeof( struct pci_dev_container   ),
		GFP_KERNEL);
	if (!dev_container) {
		LIBLCD_ERR("kzalloc");
		goto fail_alloc;
	}
	ret = glue_cap_insert_pci_dev_type(c_cspace,
		dev_container,
		&dev_container->my_ref);
	if (ret) {
		LIBLCD_ERR("lcd insert");
		goto fail_insert;
	}
563 564 565
	dev_container->pci_dev.dev.kobj.name = "ixgbe_lcd";
	dev_container->pci_dev.vendor = 0x8086;
	dev_container->pci_dev.device = 0x154D;
566 567
	dev_container->other_ref = other_ref;
	dev_container->pci_dev.dev.dma_mask = &dma_mask;
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
#ifdef PCI_REGIONS
	ret = lcd_cptr_alloc(&res0_cptr);
	if (ret) {
		LIBLCD_ERR("failed to get cptr");
		goto fail_cptr;
	}

	lcd_set_cr0(res0_cptr);
	ret = lcd_sync_recv(ixgbe_sync_endpoint);
	lcd_set_cr0(CAP_CPTR_NULL);
	/* resource len */
	res0_len = lcd_r0();
	if (ret) {
		LIBLCD_ERR("failed to recv sync");
		goto fail_sync;
	}

	ret = lcd_ioremap_phys(res0_cptr, res0_len, &gpa_addr);
	if (ret) {
		LIBLCD_ERR("failed to ioremap phys");
		goto fail_ioremap;
	}

	dev_resource_0 = lcd_ioremap(gpa_val(gpa_addr), res0_len);
	if (!dev_resource_0) {
		LIBLCD_ERR("failed to ioremap virt");
		goto fail_ioremap2;
	}
	dev_container->pci_dev.resource[0].start = (resource_size_t) dev_resource_0;
	dev_container->pci_dev.resource[0].end = (resource_size_t)((char*)dev_resource_0 + res0_len - 1);
	LIBLCD_MSG("%s: status reg 0x%X\n", __func__, *(unsigned int *)((char*)dev_resource_0 + 0x8));
#endif

601 602 603
	/* XXX: Pass null for now. struct pci_dev is passed from the
	 * kernel and needs analysis for wrapping it around a container
	 */
604
	func_ret = ixgbe_driver_container.pci_driver.probe(&dev_container->pci_dev, NULL);
605

606 607 608 609 610 611 612 613 614 615
	if (async_msg_blocking_send_start(_channel,
		&_response)) {
		LIBLCD_ERR("error getting response msg");
		return -EIO;
	}
	fipc_set_reg1(_response,
			func_ret);
	thc_ipc_reply(_channel,
			request_cookie,
			_response);
616 617 618 619 620 621 622 623
#ifdef PCI_REGIONS
fail_ioremap:
fail_ioremap2:
fail_alloc:
fail_sync:
fail_insert:
fail_cptr:
#endif
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656
	return ret;
}

void pci_unregister_driver(struct pci_driver *drv)
{
	struct pci_driver_container *drv_container;
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	drv_container = container_of(drv,
		struct pci_driver_container,
		pci_driver);
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_UNREGISTER_DRIVER);
	fipc_set_reg2(_request,
			drv_container->other_ref.cptr);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	glue_cap_remove(c_cspace,
			drv_container->my_ref);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
657 658

	return;
659 660 661 662 663
fail_async:
fail_ipc:
        destroy_async_channel(ixgbe_async);
	return;
}
664 665 666 667 668 669

int remove_callee(struct fipc_message *_request,
		struct thc_channel *_channel,
		struct glue_cspace *cspace,
		struct cptr sync_ep)
{
670 671
	/* async loop should get 0 */
	int ret = 0;
672
	struct fipc_message *_response;
673
	unsigned int __maybe_unused devfn;
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692
	unsigned 	int request_cookie;
	request_cookie = thc_get_request_cookie(_request);
	fipc_recv_msg_end(thc_channel_to_fipc(_channel),
			_request);

	/* XXX: refer the comments under probe_callee */
	ixgbe_driver_container.pci_driver.remove(NULL);

	if (async_msg_blocking_send_start(_channel,
		&_response)) {
		LIBLCD_ERR("error getting response msg");
		return -EIO;
	}
	thc_ipc_reply(_channel,
			request_cookie,
			_response);
	return ret;
}

693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
int register_netdev(struct net_device *dev)
{
	struct net_device_container *dev_container;
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
710
			REGISTER_NETDEV);
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732
	fipc_set_reg0(_request,
			dev_container->other_ref.cptr);
	fipc_set_reg1(_request,
			dev->flags);
	fipc_set_reg2(_request,
			dev->priv_flags);
	fipc_set_reg3(_request,
			dev->features);
	fipc_set_reg4(_request,
			dev->hw_features);
	fipc_set_reg5(_request,
			dev->hw_enc_features);
	fipc_set_reg6(_request,
			dev->mpls_features);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
733
	dev->reg_state = fipc_get_reg2(_response);
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;
}

void ether_setup(struct net_device *dev)
{
	struct net_device_container *dev_container;
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			ETHER_SETUP);
	fipc_set_reg1(_request,
			dev_container->other_ref.cptr);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return;
fail_async:
fail_ipc:
	return;

}

int eth_mac_addr(struct net_device *dev,
		void *p)
{
	struct net_device_container *dev_container;
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int sync_ret;
	unsigned 	long p_mem_sz;
	unsigned 	long p_offset;
	cptr_t p_cptr;
	unsigned 	int request_cookie;
	int func_ret;
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			ETH_MAC_ADDR);
	fipc_set_reg1(_request,
			dev_container->other_ref.cptr);
	sync_ret = lcd_virt_to_cptr(__gva(( unsigned  long   )p),
		&p_cptr,
		&p_mem_sz,
		&p_offset);
	if (sync_ret) {
		LIBLCD_ERR("virt to cptr failed");
		lcd_exit(-1);
	}
	ret = thc_ipc_send_request(ixgbe_async,
		_request,
		&request_cookie);
	if (ret) {
		LIBLCD_ERR("thc_ipc_send_request");
		goto fail_ipc;
	}
	lcd_set_r0(ilog2(( p_mem_sz ) >> ( PAGE_SHIFT )));
	lcd_set_r1(p_offset);
	lcd_set_cr0(p_cptr);
821
	sync_ret = lcd_sync_send(ixgbe_sync_endpoint);
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936
	lcd_set_cr0(CAP_CPTR_NULL);
	if (sync_ret) {
		LIBLCD_ERR("failed to send");
		lcd_exit(-1);
	}
	ret = thc_ipc_recv_response(ixgbe_async,
		request_cookie,
		&_response);
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;
}

int eth_validate_addr(struct net_device *dev)
{
	struct net_device_container *dev_container;
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			ETH_VALIDATE_ADDR);
	fipc_set_reg1(_request,
			dev_container->other_ref.cptr);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;
}

void free_netdev(struct net_device *dev)
{
	struct net_device_container *dev_container;
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			FREE_NETDEV);
	fipc_set_reg1(_request,
			dev_container->other_ref.cptr);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return;
fail_async:
fail_ipc:
	return;
}

void netif_carrier_off(struct net_device *dev)
{
	struct net_device_container *dev_container;
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			NETIF_CARRIER_OFF);
	fipc_set_reg1(_request,
			dev_container->other_ref.cptr);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
937

938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981
	return;
fail_async:
fail_ipc:
	return;

}

void netif_carrier_on(struct net_device *dev)
{
	struct net_device_container *dev_container;
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			NETIF_CARRIER_ON);
	fipc_set_reg1(_request,
			dev_container->other_ref.cptr);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return;
fail_async:
fail_ipc:
	return;

}

void netif_device_attach(struct net_device *dev)
{
982
	struct net_device_container *dev_container;
983 984 985
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
986 987 988
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
989 990 991 992 993 994 995 996
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			NETIF_DEVICE_ATTACH);
997 998
	fipc_set_reg1(_request,
			dev_container->other_ref.cptr);
999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return;
fail_async:
fail_ipc:
	return;
}

void netif_device_detach(struct net_device *dev)
{
1016
	struct net_device_container *dev_container;
1017 1018 1019
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
1020 1021 1022
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
1023 1024 1025 1026 1027 1028 1029 1030
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			NETIF_DEVICE_DETACH);
1031 1032
	fipc_set_reg1(_request,
			dev_container->other_ref.cptr);
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return;
fail_async:
fail_ipc:
	return;
}

int netif_set_real_num_rx_queues(struct net_device *dev,
		unsigned int rxq)
{
1051
	struct net_device_container *dev_container;
1052 1053 1054 1055
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
1056 1057 1058
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
1059 1060 1061 1062 1063 1064 1065 1066 1067
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			NETIF_SET_REAL_NUM_RX_QUEUES);
	fipc_set_reg1(_request,
1068 1069
			dev_container->other_ref.cptr);
	fipc_set_reg3(_request,
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089
			rxq);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;
}

int netif_set_real_num_tx_queues(struct net_device *dev,
		unsigned int txq)
{
1090
	struct net_device_container *dev_container;
1091 1092 1093 1094
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
1095 1096 1097
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
1098 1099 1100 1101 1102 1103 1104 1105 1106
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			NETIF_SET_REAL_NUM_TX_QUEUES);
	fipc_set_reg1(_request,
1107 1108
			dev_container->other_ref.cptr);
	fipc_set_reg3(_request,
1109
			txq);
1110
	LIBLCD_MSG("%s, setting real_num_tx_queues to %d", __func__, txq);
1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;
}

void consume_skb(struct sk_buff *skb)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			CONSUME_SKB);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return;
fail_async:
fail_ipc:
	return;

}

void unregister_netdev(struct net_device *dev)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	struct net_device_container *dev_container;

	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);

	async_msg_set_fn_type(_request,
			UNREGISTER_NETDEV);
	fipc_set_reg0(_request,
			dev_container->other_ref.cptr);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return;
fail_async:
fail_ipc:
	return;

}

int eth_platform_get_mac_address(struct device *dev,
		u8 *mac_addr)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	int i;
	union mac {
		u8 mac_addr[ETH_ALEN];
		unsigned long mac_addr_l;
	} m = { {0} };

	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			ETH_PLATFORM_GET_MAC_ADDRESS);

	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);

	if (!func_ret) {
		m.mac_addr_l = fipc_get_reg2(_response);
		memcpy(mac_addr, m.mac_addr, ETH_ALEN);
		for (i = 0; i < ETH_ALEN; i++) {
			printk("%02X:", m.mac_addr[i]);
		}
		LIBLCD_MSG("\n%s, got 0x%06lX", __func__, m.mac_addr_l);
	}

	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;
}

1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306
int dev_addr_add(struct net_device *dev,
		const unsigned char *addr,
		unsigned char addr_type)
{
	struct net_device_container *dev_container;
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int sync_ret;
	unsigned 	long addr_mem_sz;
	unsigned 	long addr_offset;
	cptr_t addr_cptr;
	unsigned 	int request_cookie;
	int func_ret;
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			DEV_ADDR_ADD);
	sync_ret = lcd_virt_to_cptr(__gva(( unsigned  long   )addr),
		&addr_cptr,
		&addr_mem_sz,
		&addr_offset);
	if (sync_ret) {
		LIBLCD_ERR("virt to cptr failed");
		lcd_exit(-1);
	}
	fipc_set_reg1(_request,
			dev_container->other_ref.cptr);
	fipc_set_reg3(_request,
			addr_type);
	ret = thc_ipc_send_request(ixgbe_async,
		_request,
		&request_cookie);
	if (ret) {
		LIBLCD_ERR("thc_ipc_send_request");
		goto fail_ipc;
	}
	lcd_set_r0(ilog2(( addr_mem_sz ) >> ( PAGE_SHIFT )));
	lcd_set_r1(addr_offset);
	lcd_set_cr0(addr_cptr);
	sync_ret = lcd_sync_send(ixgbe_sync_endpoint);
	lcd_set_cr0(CAP_CPTR_NULL);
	if (sync_ret) {
		LIBLCD_ERR("failed to send");
		lcd_exit(-1);
	}
	ret = thc_ipc_recv_response(ixgbe_async,
		request_cookie,
		&_response);
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;

}

1307 1308 1309 1310
int dev_addr_del(struct net_device *dev,
		const unsigned char *addr,
		unsigned char addr_type)
{
1311
	struct net_device_container *dev_container;
1312 1313 1314 1315 1316 1317 1318 1319 1320
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int sync_ret;
	unsigned 	long addr_mem_sz;
	unsigned 	long addr_offset;
	cptr_t addr_cptr;
	unsigned 	int request_cookie;
	int func_ret;
1321 1322 1323
	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			DEV_ADDR_DEL);
	sync_ret = lcd_virt_to_cptr(__gva(( unsigned  long   )addr),
		&addr_cptr,
		&addr_mem_sz,
		&addr_offset);
	if (sync_ret) {
		LIBLCD_ERR("virt to cptr failed");
		lcd_exit(-1);
	}
	fipc_set_reg1(_request,
1341 1342
			dev_container->other_ref.cptr);
	fipc_set_reg3(_request,
1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353
			addr_type);
	ret = thc_ipc_send_request(ixgbe_async,
		_request,
		&request_cookie);
	if (ret) {
		LIBLCD_ERR("thc_ipc_send_request");
		goto fail_ipc;
	}
	lcd_set_r0(ilog2(( addr_mem_sz ) >> ( PAGE_SHIFT )));
	lcd_set_r1(addr_offset);
	lcd_set_cr0(addr_cptr);
1354
	sync_ret = lcd_sync_send(ixgbe_sync_endpoint);
1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445
	lcd_set_cr0(CAP_CPTR_NULL);
	if (sync_ret) {
		LIBLCD_ERR("failed to send");
		lcd_exit(-1);
	}
	ret = thc_ipc_recv_response(ixgbe_async,
		request_cookie,
		&_response);
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;

}

int device_set_wakeup_enable(struct device *dev,
		bool enable)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			DEVICE_SET_WAKEUP_ENABLE);
	fipc_set_reg1(_request,
			enable);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;
}

unsigned int eth_get_headlen(void *data,
		unsigned int len)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int sync_ret;
	unsigned 	long data_mem_sz;
	unsigned 	long data_offset;
	cptr_t data_cptr;
	unsigned 	int request_cookie;
	unsigned 	int func_ret;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			ETH_GET_HEADLEN);
	sync_ret = lcd_virt_to_cptr(__gva(( unsigned  long   )data),
		&data_cptr,
		&data_mem_sz,
		&data_offset);
	if (sync_ret) {
		LIBLCD_ERR("virt to cptr failed");
		lcd_exit(-1);
	}
	fipc_set_reg1(_request,
			len);
	ret = thc_ipc_send_request(ixgbe_async,
		_request,
		&request_cookie);
	if (ret) {
		LIBLCD_ERR("thc_ipc_send_request");
		goto fail_ipc;
	}
	lcd_set_r0(ilog2(( data_mem_sz ) >> ( PAGE_SHIFT )));
	lcd_set_r1(data_offset);
	lcd_set_cr0(data_cptr);
1446
	sync_ret = lcd_sync_send(ixgbe_sync_endpoint);
1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499
	lcd_set_cr0(CAP_CPTR_NULL);
	if (sync_ret) {
		LIBLCD_ERR("failed to send");
		lcd_exit(-1);
	}
	ret = thc_ipc_recv_response(ixgbe_async,
		request_cookie,
		&_response);
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;
}

void netif_tx_stop_all_queues(struct net_device *dev)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	struct net_device_container *dev_container;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}

	dev_container = container_of(dev,
		struct net_device_container,
		net_device);
	async_msg_set_fn_type(_request,
			NETIF_TX_STOP_ALL_QUEUES);

	fipc_set_reg0(_request,
			dev_container->other_ref.cptr);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return;
fail_async:
fail_ipc:
	return;
}

1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534
void _netif_tx_wake_all_queues(struct net_device *dev)
{
	struct net_device_container *dev_queue_container;
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	dev_queue_container = container_of(dev,
		struct net_device_container,
		net_device);
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			NETIF_TX_WAKE_ALL_QUEUES);
	fipc_set_reg1(_request,
			dev_queue_container->other_ref.cptr);
	fipc_set_reg2(_request,
			dev->num_tx_queues);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return;
fail_async:
fail_ipc:
	return;
}
1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839

int pci_disable_pcie_error_reporting(struct pci_dev *dev)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_DISABLE_PCIE_ERROR_REPORTING);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;
}

int pci_bus_read_config_word(struct pci_bus *bus,
		unsigned int devfn,
		int where,
		unsigned short *val)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_BUS_READ_CONFIG_WORD);
	fipc_set_reg1(_request,
			devfn);
	fipc_set_reg2(_request,
			where);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	*val = fipc_get_reg1(_response);
	func_ret = fipc_get_reg2(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;

}

int pci_bus_write_config_word(struct pci_bus *bus,
		unsigned int devfn,
		int where,
		unsigned short val)
{
	struct pci_bus_container *bus_container;
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	bus_container = container_of(bus,
		struct pci_bus_container,
		pci_bus);
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_BUS_WRITE_CONFIG_WORD);
	fipc_set_reg1(_request,
			bus_container->other_ref.cptr);
	fipc_set_reg3(_request,
			devfn);
	fipc_set_reg4(_request,
			where);
	fipc_set_reg5(_request,
			val);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;

}

int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_CLEANUP_AER_UNCORRECT_ERROR_STATUS);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;

}

void pci_disable_device(struct pci_dev *dev)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_DISABLE_DEVICE);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return;
fail_async:
fail_ipc:
	return;
}

int pci_enable_pcie_error_reporting(struct pci_dev *dev)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_ENABLE_PCIE_ERROR_REPORTING);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;

}

int pcie_capability_read_word(struct pci_dev *dev,
		int pos,
		unsigned short *val)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCIE_CAPABILITY_READ_WORD);
	fipc_set_reg1(_request,
			pos);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;

}

int pcie_get_minimum_link(struct pci_dev *dev,
		enum pci_bus_speed *speed,
		enum pcie_link_width *width)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCIE_GET_MINIMUM_LINK);
	fipc_set_reg1(_request,
			*speed);
	fipc_set_reg2(_request,
			*width);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;

}

int pci_enable_device_mem(struct pci_dev *dev)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_ENABLE_DEVICE_MEM);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
1840
	return func_ret;
1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068
}

int pci_request_selected_regions(struct pci_dev *dev,
		int type,
		const char *reg)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_REQUEST_SELECTED_REGIONS);
	fipc_set_reg1(_request,
			type);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;
}

int pci_request_selected_regions_exclusive(struct pci_dev *dev,
		int type,
		const char *reg)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_REQUEST_SELECTED_REGIONS_EXCLUSIVE);
	fipc_set_reg1(_request,
			type);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;

}

void pci_set_master(struct pci_dev *dev)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_SET_MASTER);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return;
fail_async:
fail_ipc:
	return;

}

int pci_save_state(struct pci_dev *dev)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_SAVE_STATE);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return ret;

}

void pci_release_selected_regions(struct pci_dev *dev,
		int r)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_RELEASE_SELECTED_REGIONS);
	fipc_set_reg1(_request,
			r);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return;
fail_async:
fail_ipc:
	return;

}

int pci_select_bars(struct pci_dev *dev,
		unsigned long flags)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	ret = async_msg_blocking_send_start(ixgbe_async,
		&_request);
	if (ret) {
		LIBLCD_ERR("failed to get a send slot");
		goto fail_async;
	}
	async_msg_set_fn_type(_request,
			PCI_SELECT_BARS);
	fipc_set_reg1(_request,
			flags);
	ret = thc_ipc_call(ixgbe_async,
		_request,
		&_response);
	if (ret) {
		LIBLCD_ERR("thc_ipc_call");
		goto fail_ipc;
	}
	func_ret = fipc_get_reg1(_response);
	fipc_recv_msg_end(thc_channel_to_fipc(ixgbe_async),
			_response);
	return func_ret;
fail_async:
fail_ipc:
	return func_ret;

}

int pci_wake_from_d3(struct pci_dev *dev,
		bool enable)
{
	int ret;
	struct fipc_message *_request;
	struct fipc_message *_response;
	int func_ret;
	ret =