ServerEngines 10Gb NIC driver
Subsystems (2)
PATCH 7/16 ServerEngines 10Gb NIC driver
Ether ring creation function in beclib.
---------------------------------------
linux-2.6.24.2/drivers/message/beclib/ethtx_ll.c 2008-02-14 15:23:07.806206040 +0530 renamed from linux-2.6.24.2/drivers/message/beclib/ethtx_ll.c 1970-01-01 05:30:00.000000000 +0530 +561 -0
@@ -0,0 +1,561 @@ +/* + * Copyright (C) 2005 - 2008 ServerEngines + * All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or at your option any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, 5th Floor + * Boston, MA 02110-1301 USA + * + * + * The full GNU General Public License is included in this distribution + * in the file called GPL. + * + * Contact Information: + * [email protected] + * + * ServerEngines + * 209 N. Fair Oaks Ave + * Sunnyvale, CA 94085 + * + */ +#include "pch.h" + +/* + *--------------------------------------------------------- + * Function: be_eth_sq_create_ex + * Creates an ethernet send ring - extended version with + * additional parameters. + * function_object - + * sgl - no virtual address required + * length_in_bytes - + * type - The type of ring to create. + * ulp - The requested ULP number for the ring. + * This should be zero based, i.e. 0,1,2. This must + * be valid NIC ULP based on the firmware config. + * All doorbells for this ring must be sent to + * this ULP. The first network ring allocated for + * each ULP are higher performance than subsequent rings. + * cq_object - cq object for completions + * ex_parameters - Additional parameters (that may increase in + * future revisions). These parameters are only used + * for certain ring types -- see + * BE_ETH_SQ_PARAMETERS for details. + * eth_sq - + * return status - BE_SUCCESS (0) on success. Negative error code on failure. + *--------------------------------------------------------- + */ +BESTATUS +be_eth_sq_create_ex(IN PBE_FUNCTION_OBJECT function_object, + IN PSA_SGL sgl, + IN u32 length, + IN u32 type, + IN u32 ulp, + IN PBE_CQ_OBJECT cq_object, + IN BE_ETH_SQ_PARAMETERS *ex_parameters, + OUT PBE_ETHSQ_OBJECT eth_sq) +{ + IOCTL_COMMON_ETH_TX_CREATE *ioctl = NULL; + MCC_WRB *wrb = NULL; + BESTATUS status = 0; + + ASSERT(sgl); + ASSERT(eth_sq); + ASSERT(ex_parameters); + + FUNCTION_ASSERT(function_object); + be_lock_wrb_post(function_object); + + sa_zero_mem(eth_sq, sizeof(*eth_sq)); + + eth_sq->magic = BE_ETHSQ_MAGIC; + eth_sq->parent_function = function_object; + eth_sq->bid = 0xFFFFFFFF; + eth_sq->cq_object = cq_object; + + /* Translate beclib interface to arm interface. */ + switch (type) { + case BE_ETH_TX_RING_TYPE_FORWARDING: + type = ETH_TX_RING_TYPE_FORWARDING; + break; + case BE_ETH_TX_RING_TYPE_STANDARD: + type = ETH_TX_RING_TYPE_STANDARD; + break; + case BE_ETH_TX_RING_TYPE_BOUND: + ASSERT(ex_parameters->port < 2); + type = ETH_TX_RING_TYPE_BOUND; + break; + default: + TRACE(DL_ERR, "Invalid eth tx ring type:%d", type); + return BE_NOT_OK; + break; + } + + wrb = be_function_peek_mcc_wrb(function_object); + if (!wrb) { + ASSERT(wrb); + TRACE(DL_ERR, "No free MCC WRBs in create EQ."); + status = BE_STATUS_NO_MCC_WRB; + goto Error; + } + /* NIC must be supported by the current config. */ + ASSERT(function_object->fw_config.nic_ulp_mask); + + /* + * The ulp parameter must select a valid NIC ULP + * for the current config. + */ + ASSERT((1 << ulp) & function_object->fw_config.nic_ulp_mask); + + /* Prepares an embedded ioctl, including request/response sizes. */ + ioctl = + BE_FUNCTION_PREPARE_EMBEDDED_IOCTL(function_object, wrb, + COMMON_ETH_TX_CREATE); + + /* Only used for ETH_TX_RING_TYPE_BOUND */ + ioctl->header.request.port_number = ex_parameters->port; + ioctl->params.request.context.pd_id = + be_function_get_pd_number(function_object); + ioctl->params.request.context.tx_ring_size = + be_ring_length_to_encoding(length, sizeof(ETH_WRB)); + ioctl->params.request.context.cq_id_send = cq_object->cq_id; + ioctl->params.request.context.func = + be_function_get_function_number(function_object); + ioctl->params.request.type = type; + ioctl->params.request.ulp_num = (1 << ulp); + + ioctl->params.request.num_pages = sa_ceiling(length, SA_PAGE_SIZE); + ASSERT(sa_sgl_get_page_count(sgl) >= + ioctl->params.request.num_pages); + + /* Create a page list for the IOCTL. */ + be_sgl_to_pa_list(sgl, + ioctl->params.request.pages, + SA_NUMBER_OF(ioctl->params.request.pages)); + + status = + be_function_post_mcc_wrb(function_object, wrb, NULL, NULL, + ioctl); + if (status != BE_SUCCESS) { + TRACE(DL_ERR, "MCC to create etx queue failed."); + goto Error; + } + /* save the butler ID */ + eth_sq->bid = ioctl->params.response.cid; + + /* add a reference to the corresponding CQ */ + be_cq_object_reference(cq_object); + + /* add this object to the function object */ + _be_function_add_eth_sq(function_object, eth_sq); + + TRACE(DL_INFO, + "eth sq created. function:%d pd:%d bid:%d bytes:%d cq_id:%d", + be_function_get_function_number(function_object), + be_function_get_pd_number(function_object), eth_sq->bid, + length, be_cq_get_id(cq_object)); +Error: + be_unlock_wrb_post(function_object); + return status; + +} + +/*! + +@brief + this routine creates an ethernet send queue + +@param + function_object - handle to a function object +@param + send_queue_va - base VA for a the ethernet send ring +@param + ring_size_power_of_two - number of entries in the + ring (power of two). 32K = 0, 1 = rsvd, + 2 = 1, 3 = 4 .... +@param + cq_object - internal CQ handle returned. +@param + pp_eth_sq - internal eth sq handle returned. + +@return + BE_SUCCESS if successfull, , otherwise a useful error code is returned. + +@note + IRQL: < DISPATCH_LEVEL + this function allocates an eth_sq object + +*/ +BESTATUS be_eth_sq_create(IN PBE_FUNCTION_OBJECT function_object, + IN PSA_SGL sgl, IN u32 length, IN u32 type, + IN u32 ulp, /* 0,1,2 ulp id for the request ring */ + IN PBE_CQ_OBJECT cq_object, + OUT PBE_ETHSQ_OBJECT eth_sq) +{ + BE_ETH_SQ_PARAMETERS ex_parameters = { 0 }; + + return be_eth_sq_create_ex(function_object, + sgl, + length, + type, + ulp, cq_object, &ex_parameters, eth_sq); +} + +/*! + +@brief + This routine returns the RID for an Etx SQ + +@param + EthSq - EthSq Handle returned from EthSqCreate + +@return + The RID for an Etx SQ + +@note + +*/ +u32 be_eth_sq_get_id(IN PBE_ETHSQ_OBJECT eth_sq) +{ + ETHSQ_ASSERT(eth_sq); + return eth_sq->bid; +} + +/*! + +@brief + This routine destroys an ethernet send queue + +@param + EthSq - EthSq Handle returned from EthSqCreate + +@return + This function always return BE_SUCCESS. + +@note + This function frees memory allocated by EthSqCreate for the EthSq Object. + +*/ +BESTATUS be_eth_sq_destroy(IN PBE_ETHSQ_OBJECT eth_sq) +{ + BESTATUS status = 0; + + ETHSQ_ASSERT(eth_sq); + + /* Send ioctl to destroy the queue. */ + status = + be_function_ring_destroy(eth_sq->parent_function, eth_sq->bid, + IOCTL_RING_TYPE_ETH_TX); + ASSERT(status == 0); + + /* Derefence any associated CQs. */ + be_cq_object_dereference(eth_sq->cq_object); + + /* Remove from function */ + _be_function_remove_eth_sq(eth_sq->parent_function, eth_sq); + + /* Clear tracking object */ + sa_zero_mem(eth_sq, sizeof(*eth_sq)); + + return status; +} + +/*! + +@brief + This routine attempts to set the transmit flow control parameters. + +@param + FunctionObject - Handle to a function object + +@param + txfc_enable - transmit flow control enable - true for + enable, false for disable + +@param + rxfc_enable - receive flow control enable - true for + enable, false for disable + +@return + BE_SUCCESS if successfull, otherwise a useful BESTATUS error + code is returned. + +@note + IRQL: < DISPATCH_LEVEL + + This function always fails in non-privileged machine context. +*/ +BESTATUS +be_eth_set_flow_control(IN PBE_FUNCTION_OBJECT function_object, + IN boolean txfc_enable, IN boolean rxfc_enable) +{ + IOCTL_COMMON_SET_FLOW_CONTROL *ioctl = NULL; + MCC_WRB *wrb = NULL; + BESTATUS status = 0; + + be_lock_wrb_post(function_object); + + wrb = be_function_peek_mcc_wrb(function_object); + if (!wrb) { + TRACE(DL_ERR, "MCC wrb peek failed."); + status = BE_STATUS_NO_MCC_WRB; + goto error; + } + /* Prepares an embedded ioctl, including request/response sizes. */ + ioctl = + BE_FUNCTION_PREPARE_EMBEDDED_IOCTL(function_object, wrb, + COMMON_SET_FLOW_CONTROL); + + ioctl->params.request.rx_flow_control = rxfc_enable; + ioctl->params.request.tx_flow_control = txfc_enable; + + /* Post the Ioctl */ + status = be_function_post_mcc_wrb(function_object, wrb, NULL, + NULL, ioctl); + + if (status != 0) { + TRACE(DL_ERR, "set flow control ioctl failed."); + goto error; + } + +error: + be_unlock_wrb_post(function_object); + + return status; +} + +/*! + +@brief + This routine attempts to get the transmit flow control parameters. + +@param + FunctionObject - Handle to a function object + +@param + txfc_enable - transmit flow control enable - true for + enable, false for disable + +@param + rxfc_enable - receive flow control enable - true for enable, + false for disable + +@return + BE_SUCCESS if successfull, otherwise a useful BESTATUS error code + is returned. + +@note + IRQL: < DISPATCH_LEVEL + + This function always fails in non-privileged machine context. +*/ +BESTATUS +be_eth_get_flow_control(IN PBE_FUNCTION_OBJECT function_object, + IN boolean *txfc_enable, IN boolean *rxfc_enable) +{ + IOCTL_COMMON_GET_FLOW_CONTROL *ioctl = NULL; + MCC_WRB *wrb = NULL; + BESTATUS status = 0; + + be_lock_wrb_post(function_object); + + wrb = be_function_peek_mcc_wrb(function_object); + if (!wrb) { + TRACE(DL_ERR, "MCC wrb peek failed."); + status = BE_STATUS_NO_MCC_WRB; + goto error; + } + /* Prepares an embedded ioctl, including request/response sizes. */ + ioctl = + BE_FUNCTION_PREPARE_EMBEDDED_IOCTL(function_object, wrb, + COMMON_GET_FLOW_CONTROL); + + /* Post the Ioctl */ + status = be_function_post_mcc_wrb(function_object, wrb, NULL, + NULL, ioctl); + + if (status != 0) { + TRACE(DL_ERR, "get flow control ioctl failed."); + goto error; + } + + *txfc_enable = ioctl->params.response.tx_flow_control; + *rxfc_enable = ioctl->params.response.rx_flow_control; + +error: + be_unlock_wrb_post(function_object); + + return status; +} + +/* + *--------------------------------------------------------- + * Function: be_eth_set_qos + * This function sets the ethernet transmit Quality of Service (QoS) + * characteristics of BladeEngine for the domain. All ethernet + * transmit rings of the domain will evenly share the bandwidth. + * The exeception to sharing is the host primary (super) ethernet + * transmit ring as well as the host ethernet forwarding ring + * for missed offload data. + * function_object - + * max_bps - the maximum bits per second in units of + * 10 Mbps (valid 0-100) + * max_pps - the maximum packets per second in units + * of 1 Kpps (0 indicates no limit) + * return status - BE_SUCCESS (0) on success. Negative error code on failure. + *--------------------------------------------------------- + */ +BESTATUS +be_eth_set_qos(IN PBE_FUNCTION_OBJECT function_object, + IN u32 max_bps, IN u32 max_pps) +{ + IOCTL_COMMON_SET_QOS *ioctl = NULL; + MCC_WRB *wrb = NULL; + BESTATUS status = 0; + + be_lock_wrb_post(function_object); + + wrb = be_function_peek_mcc_wrb(function_object); + if (!wrb) { + TRACE(DL_ERR, "MCC wrb peek failed."); + status = BE_STATUS_NO_MCC_WRB; + goto error; + } + /* Prepares an embedded ioctl, including request/response sizes. */ + ioctl = + BE_FUNCTION_PREPARE_EMBEDDED_IOCTL(function_object, wrb, + COMMON_SET_QOS); + + /* Set fields in ioctl */ + ioctl->params.request.max_bits_per_second_NIC = max_bps; + ioctl->params.request.max_packets_per_second_NIC = max_pps; + ioctl->params.request.valid_flags = QOS_BITS_NIC | QOS_PKTS_NIC; + + /* Post the Ioctl */ + status = be_function_post_mcc_wrb(function_object, wrb, NULL, + NULL, ioctl); + + if (status != 0) { + TRACE(DL_ERR, "network set qos ioctl failed."); + } + +error: + be_unlock_wrb_post(function_object); + + return status; +} + +/* + *--------------------------------------------------------- + * Function: be_eth_get_qos + * This function retrieves the ethernet transmit Quality of Service (QoS) + * characteristics for the domain. + * function_object - + * max_bps - the maximum bits per second in units of + * 10 Mbps (valid 0-100) + * max_pps - the maximum packets per second in units of + * 1 Kpps (0 indicates no limit) + * return status - BE_SUCCESS (0) on success. Negative error code on failure. + *--------------------------------------------------------- + */ +BESTATUS +be_eth_get_qos(IN PBE_FUNCTION_OBJECT function_object, + IN u32 *max_bps, IN u32 *max_pps) +{ + IOCTL_COMMON_GET_QOS *ioctl = NULL; + MCC_WRB *wrb = NULL; + BESTATUS status = 0; + + be_lock_wrb_post(function_object); + + wrb = be_function_peek_mcc_wrb(function_object); + if (!wrb) { + TRACE(DL_ERR, "MCC wrb peek failed."); + status = BE_STATUS_NO_MCC_WRB; + goto error; + } + /* Prepares an embedded ioctl, including request/response sizes. */ + ioctl = + BE_FUNCTION_PREPARE_EMBEDDED_IOCTL(function_object, wrb, + COMMON_GET_QOS); + + /* Post the Ioctl */ + status = be_function_post_mcc_wrb(function_object, wrb, NULL, + NULL, ioctl); + + if (status != 0) { + TRACE(DL_ERR, "network get qos ioctl failed."); + goto error; + } + + *max_bps = ioctl->params.response.max_bits_per_second_NIC; + *max_pps = ioctl->params.response.max_packets_per_second_NIC; + +error: + be_unlock_wrb_post(function_object); + + return status; +} + +/* + *--------------------------------------------------------- + * Function: be_eth_set_frame_size + * This function sets the ethernet maximum frame size. The previous + * values are returned. + * function_object - + * tx_frame_size - maximum transmit frame size in bytes + * rx_frame_size - maximum receive frame size in bytes + * return status - BE_SUCCESS (0) on success. Negative error code on failure. + *--------------------------------------------------------- + */ +BESTATUS +be_eth_set_frame_size(IN PBE_FUNCTION_OBJECT function_object, + IN OUT u32 *tx_frame_size, + IN OUT u32 *rx_frame_size) +{ + IOCTL_COMMON_SET_FRAME_SIZE *ioctl = NULL; + MCC_WRB *wrb = NULL; + BESTATUS status = 0; + + be_lock_wrb_post(function_object); + + wrb = be_function_peek_mcc_wrb(function_object); + if (!wrb) { + TRACE(DL_ERR, "MCC wrb peek failed."); + status = BE_STATUS_NO_MCC_WRB; + goto error; + } + /* Prepares an embedded ioctl, including request/response sizes. */ + ioctl = + BE_FUNCTION_PREPARE_EMBEDDED_IOCTL(function_object, wrb, + COMMON_SET_FRAME_SIZE); + ioctl->params.request.max_tx_frame_size = *tx_frame_size; + ioctl->params.request.max_rx_frame_size = *rx_frame_size; + + /* Post the Ioctl */ + status = be_function_post_mcc_wrb(function_object, wrb, NULL, + NULL, ioctl); + + if (status != 0) { + TRACE(DL_ERR, "network set frame size ioctl failed."); + goto error; + } + + *tx_frame_size = ioctl->params.response.chip_max_tx_frame_size; + *rx_frame_size = ioctl->params.response.chip_max_rx_frame_size; + +error: + be_unlock_wrb_post(function_object); + + return status; +}
linux-2.6.24.2/drivers/message/beclib/ethrx_ll.c 2008-02-14 15:23:07.807205888 +0530 renamed from linux-2.6.24.2/drivers/message/beclib/ethrx_ll.c 1970-01-01 05:30:00.000000000 +0530 +430 -0
430 lines not on this page · raw message
linux-2.6.24.2/drivers/message/beclib/rxf_ll.c 2008-02-14 15:32:13.489249608 +0530 renamed from linux-2.6.24.2/drivers/message/beclib/rxf_ll.c 1970-01-01 05:30:00.000000000 +0530 +1008 -0
1,008 lines not on this page · raw message
___________________________________________________________________________________
This message, together with any attachment(s), contains confidential and proprietary information of ServerEngines Corporation and is intended only for the designated recipient(s) named above. Any unauthorized review, printing, retention, copying, disclosure or distribution is strictly prohibited. If you are not the intended recipient of this message, please immediately advise the sender by reply email message and delete all copies of this message and any attachment(s). Thank you.