Print this page
NEX-1890 update oce from source provided by Emulex
*** 17,40 ****
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
! /* Copyright © 2003-2011 Emulex. All rights reserved. */
/*
* Source file containing the implementation of the driver
* helper functions
*/
#include <oce_impl.h>
- static void oce_list_del_node(OCE_LIST_NODE_T *prev_node,
- OCE_LIST_NODE_T *next_node);
- static void oce_list_remove(OCE_LIST_NODE_T *list_node);
- static void oce_list_insert_node(OCE_LIST_NODE_T *list_node,
- OCE_LIST_NODE_T *prev_node, OCE_LIST_NODE_T *next_node);
/*
* function to breakup a block of memory into pages and return the address
* in an array
*
* dbuf - pointer to structure describing DMA-able memory
--- 17,40 ----
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
! /*
! * Copyright (c) 2009-2012 Emulex. All rights reserved.
! * Use is subject to license terms.
! */
+
+
/*
* Source file containing the implementation of the driver
* helper functions
*/
#include <oce_impl.h>
/*
* function to breakup a block of memory into pages and return the address
* in an array
*
* dbuf - pointer to structure describing DMA-able memory
*** 49,219 ****
uint64_t paddr = 0;
ASSERT(dbuf != NULL);
ASSERT(pa_list != NULL);
! paddr = DBUF_PA(dbuf);
for (i = 0; i < list_size; i++) {
pa_list[i].lo = ADDR_LO(paddr);
pa_list[i].hi = ADDR_HI(paddr);
paddr += PAGE_4K;
}
} /* oce_page_list */
void
- oce_list_link_init(OCE_LIST_NODE_T *list_node)
- {
- list_node->next = NULL;
- list_node->prev = NULL;
- }
-
- static inline void
- oce_list_insert_node(OCE_LIST_NODE_T *list_node, OCE_LIST_NODE_T *prev_node,
- OCE_LIST_NODE_T *next_node)
- {
- next_node->prev = list_node;
- list_node->next = next_node;
- list_node->prev = prev_node;
- prev_node->next = list_node;
- }
-
- static inline void
- oce_list_del_node(OCE_LIST_NODE_T *prev_node, OCE_LIST_NODE_T *next_node)
- {
- next_node->prev = prev_node;
- prev_node->next = next_node;
- }
-
- static inline void
- oce_list_remove(OCE_LIST_NODE_T *list_node)
- {
- oce_list_del_node(list_node->prev, list_node->next);
- list_node->next = list_node->prev = NULL;
- }
-
- void
- oce_list_create(OCE_LIST_T *list_hdr, void *arg)
- {
- list_hdr->head.next = list_hdr->head.prev = &list_hdr->head;
- mutex_init(&list_hdr->list_lock, NULL, MUTEX_DRIVER, arg);
- list_hdr->nitems = 0;
- }
-
- void
- oce_list_destroy(OCE_LIST_T *list_hdr)
- {
- ASSERT(list_hdr->nitems == 0);
- list_hdr->head.next = list_hdr->head.prev = NULL;
- mutex_destroy(&list_hdr->list_lock);
-
- }
-
- void
- oce_list_insert_tail(OCE_LIST_T *list_hdr, OCE_LIST_NODE_T *list_node)
- {
- OCE_LIST_NODE_T *head = &list_hdr->head;
-
- ASSERT(list_hdr != NULL);
- ASSERT(list_node != NULL);
-
- mutex_enter(&list_hdr->list_lock);
- oce_list_insert_node(list_node, head->prev, head);
- list_hdr->nitems++;
- mutex_exit(&list_hdr->list_lock);
- }
-
- void
- oce_list_insert_head(OCE_LIST_T *list_hdr, OCE_LIST_NODE_T *list_node)
- {
- OCE_LIST_NODE_T *head = &list_hdr->head;
-
- ASSERT(list_hdr != NULL);
- ASSERT(list_node != NULL);
-
- mutex_enter(&list_hdr->list_lock);
- oce_list_insert_node(list_node, head, head->next);
- list_hdr->nitems++;
- mutex_exit(&list_hdr->list_lock);
- }
-
- void *
- oce_list_remove_tail(OCE_LIST_T *list_hdr)
- {
- OCE_LIST_NODE_T *list_node;
-
- if (list_hdr == NULL) {
- return (NULL);
- }
-
- mutex_enter(&list_hdr->list_lock);
-
- if (list_hdr->nitems <= 0) {
- mutex_exit(&list_hdr->list_lock);
- return (NULL);
- }
-
- list_node = list_hdr->head.prev;
- oce_list_remove(list_node);
- list_hdr->nitems--;
- mutex_exit(&list_hdr->list_lock);
- return (list_node);
- }
-
- void *
- oce_list_remove_head(OCE_LIST_T *list_hdr)
- {
- OCE_LIST_NODE_T *list_node;
-
- if (list_hdr == NULL) {
- return (NULL);
- }
-
- mutex_enter(&list_hdr->list_lock);
-
- if (list_hdr->nitems <= 0) {
- mutex_exit(&list_hdr->list_lock);
- return (NULL);
- }
-
- list_node = list_hdr->head.next;
-
- if (list_node != NULL) {
- oce_list_remove(list_node);
- list_hdr->nitems--;
- }
-
- mutex_exit(&list_hdr->list_lock);
- return (list_node);
- }
-
- boolean_t
- oce_list_is_empty(OCE_LIST_T *list_hdr)
- {
- if (list_hdr == NULL)
- return (B_TRUE);
- else
- return (list_hdr->nitems <= 0);
- }
-
- int
- oce_list_items_avail(OCE_LIST_T *list_hdr)
- {
- if (list_hdr == NULL)
- return (0);
- else
- return (list_hdr->nitems);
- }
-
- void
- oce_list_remove_node(OCE_LIST_T *list_hdr, OCE_LIST_NODE_T *list_node)
- {
- mutex_enter(&list_hdr->list_lock);
- oce_list_remove(list_node);
- mutex_exit(&list_hdr->list_lock);
- }
-
- void
oce_gen_hkey(char *hkey, int key_size)
{
int i;
int nkeys = key_size/sizeof (uint32_t);
for (i = 0; i < nkeys; i++) {
--- 49,67 ----
uint64_t paddr = 0;
ASSERT(dbuf != NULL);
ASSERT(pa_list != NULL);
! paddr = DBUF_PA(*dbuf);
for (i = 0; i < list_size; i++) {
pa_list[i].lo = ADDR_LO(paddr);
pa_list[i].hi = ADDR_HI(paddr);
paddr += PAGE_4K;
}
} /* oce_page_list */
void
oce_gen_hkey(char *hkey, int key_size)
{
int i;
int nkeys = key_size/sizeof (uint32_t);
for (i = 0; i < nkeys; i++) {
*** 239,244 ****
--- 87,129 ----
newval = oldval - n;
} while (atomic_cas_32(count_p, oldval, newval) != oldval);
return (newval);
+ }
+
+
+ /*
+ * function to insert vtag to packet
+ *
+ * mp - mblk pointer
+ * vlan_tag - tag to be inserted
+ *
+ * return none
+ */
+ void
+ oce_insert_vtag(mblk_t *mp, uint16_t vlan_tag)
+ {
+ struct ether_vlan_header *evh;
+ (void) memmove(mp->b_rptr - VTAG_SIZE,
+ mp->b_rptr, 2 * ETHERADDRL);
+ mp->b_rptr -= VTAG_SIZE;
+ evh = (struct ether_vlan_header *)(void *)mp->b_rptr;
+ evh->ether_tpid = htons(VLAN_TPID);
+ evh->ether_tci = htons(vlan_tag);
+ }
+
+ /*
+ * function to strip vtag from packet
+ *
+ * mp - mblk pointer
+ *
+ * return none
+ */
+
+ void
+ oce_remove_vtag(mblk_t *mp)
+ {
+ (void) memmove(mp->b_rptr + VTAG_SIZE, mp->b_rptr,
+ ETHERADDRL * 2);
+ mp->b_rptr += VTAG_SIZE;
}