client_tx.c (3668B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * File: client_tx.c 8 * Purpose: Client implementation of bcm_tx* functions. 9 * Requires: 10 */ 11 12 #include <shared/bsl.h> 13 14 #include <bcm/tx.h> 15 #include <bcm/error.h> 16 17 #if defined(BROADCOM_DEBUG) 18 #include <soc/debug.h> 19 #include <soc/cm.h> 20 #define TX_DEBUG(stuff) LOG_ERROR(BSL_LS_SOC_COMMON, stuff) 21 #else 22 #define TX_DEBUG(stuff) 23 #endif /* BROADCOM_DEBUG */ 24 25 26 /* 27 * Function: 28 * bcm_client_tx_init 29 * Purpose: 30 * Initialize BCM TX API on client 31 * Parameters: 32 * unit - transmission unit 33 * Returns: 34 * BCM_E_XXX 35 * Notes: 36 */ 37 38 int 39 bcm_client_tx_init(int unit) 40 { 41 /* Set up TX tunnel receiver and transmitter */ 42 /* Currently this is done elsewhere */ 43 return BCM_E_NONE; 44 } 45 46 /* 47 * Function: 48 * bcm_client_tx 49 * Purpose: 50 * Transmit a single packet on client 51 * Parameters: 52 * unit - transmission unit 53 * pkt - The tx packet structure 54 * cookie - Callback cookie when tx done 55 * Returns: 56 * BCM_E_XXX 57 * Notes: 58 * XGS3 devices cannot dispatch packets to multiple ports. To emulate this 59 * functionality, bcm_tx iterates over the requested bitmaps. The callback, 60 * if applicable, shall be called only once. 61 */ 62 63 int 64 bcm_client_tx(int unit, bcm_pkt_t *pkt, void *cookie) 65 { 66 /* Tunnel the packet to the remote CPU */ 67 bcm_cpu_tunnel_mode_t mode = BCM_CPU_TUNNEL_PACKET; /* default */ 68 69 if (pkt->call_back != NULL && cookie != NULL) { 70 TX_DEBUG(("bcm_tx ERROR: " 71 "Cookie non-NULL on async tunnel call\n")); 72 return BCM_E_PARAM; 73 } 74 75 if (pkt->flags & BCM_TX_BEST_EFFORT) { 76 mode = BCM_CPU_TUNNEL_PACKET_BEST_EFFORT; 77 } else if (pkt->flags & BCM_TX_RELIABLE) { 78 mode = BCM_CPU_TUNNEL_PACKET_RELIABLE; 79 } 80 81 return bcm_tx_cpu_tunnel(pkt, unit, 0, BCM_CPU_TUNNEL_F_PBMP, mode); 82 } 83 84 /* 85 * Function: 86 * bcm_client_tx_array 87 * Purpose: 88 * Transmit an array of packets on client 89 * Parameters: 90 * unit - transmission unit 91 * pkt - array of pointers to packets to transmit 92 * count - Number of packets in list 93 * all_done_cb - Callback function (if non-NULL) when all pkts trx'd 94 * cookie - Callback cookie. 95 * Returns: 96 * BCM_E_XXX 97 * Notes: 98 * Can't tunnel an array to the client, so return error. 99 */ 100 101 int 102 bcm_client_tx_array(int unit, bcm_pkt_t **pkt, int count, 103 bcm_pkt_cb_f all_done_cb, void *cookie) 104 { 105 TX_DEBUG(("bcm_tx_array ERROR: Cannot tunnel\n")); 106 return BCM_E_PARAM; 107 } 108 109 /* 110 * Function: 111 * bcm_client_tx_list 112 * Purpose: 113 * Transmit a linked list of packets 114 * Parameters: 115 * unit - transmission unit 116 * pkt - Pointer to linked list of packets 117 * all_done_cb - Callback function (if non-NULL) when all pkts trx'd 118 * cookie - Callback cookie. 119 * Returns: 120 * BCM_E_XXX 121 * Notes: 122 * Can't tunnel a list to the client, so return error. 123 */ 124 125 int 126 bcm_client_tx_list(int unit, bcm_pkt_t *pkt, bcm_pkt_cb_f all_done_cb, 127 void *cookie) 128 { 129 TX_DEBUG(("bcm_tx_list ERROR: Cannot tunnel\n")); 130 return BCM_E_PARAM; 131 } 132 133 /* 134 * Function: 135 * bcm_client_tx_pkt_setup 136 * Purpose: 137 * Default packet setup routine for transmit on client 138 * Parameters: 139 * unit - Unit on which being transmitted 140 * tx_pkt - Packet to update 141 * Returns: 142 * BCM_E_XXX 143 * Notes: 144 */ 145 146 int 147 bcm_client_tx_pkt_setup(int unit, bcm_pkt_t *tx_pkt) 148 { 149 return BCM_E_NONE; 150 }