/* * Shared Transport Line discipline driver Core * Init Manager module responsible for GPIO control * and firmware download * Copyright (C) 2009-2010 Texas Instruments * Author: Pavan Savoy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #define pr_fmt(fmt) "(stk) :" fmt #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define MAX_ST_DEVICES 3 /* Imagine 1 on each UART for now */ static struct platform_device *st_kim_devices[MAX_ST_DEVICES]; /**********************************************************************/ /* internal functions */ struct ti_st_plat_data *dt_pdata; static struct ti_st_plat_data *get_platform_data(struct device *dev); /** * st_get_plat_device - * function which returns the reference to the platform device * requested by id. As of now only 1 such device exists (id=0) * the context requesting for reference can get the id to be * requested by a. The protocol driver which is registering or * b. the tty device which is opened. */ static struct platform_device *st_get_plat_device(int id) { return st_kim_devices[id]; } /** * validate_firmware_response - * function to return whether the firmware response was proper * in case of error don't complete so that waiting for proper * response times out */ static void validate_firmware_response(struct kim_data_s *kim_gdata) { struct sk_buff *skb = kim_gdata->rx_skb; if (!skb) return; /* these magic numbers are the position in the response buffer which * allows us to distinguish whether the response is for the read * version info. command */ if (skb->data[2] == 0x01 && skb->data[3] == 0x01 && skb->data[4] == 0x10 && skb->data[5] == 0x00) { /* fw version response */ memcpy(kim_gdata->resp_buffer, kim_gdata->rx_skb->data, kim_gdata->rx_skb->len); complete_all(&kim_gdata->kim_rcvd); kim_gdata->rx_state = ST_W4_PACKET_TYPE; kim_gdata->rx_skb = NULL; kim_gdata->rx_count = 0; } else if (unlikely(skb->data[5] != 0)) { pr_err("no proper response during fw download"); pr_err("data6 %x", skb->data[5]); kfree_skb(skb); return; /* keep waiting for the proper response */ } /* becos of all the script being downloaded */ complete_all(&kim_gdata->kim_rcvd); kfree_skb(skb); } /* check for data len received inside kim_int_recv * most often hit the last case to update state to waiting for data */ static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len) { register int room = skb_tailroom(kim_gdata->rx_skb); pr_debug("len %d room %d", len, room); if (!len) { validate_firmware_response(kim_gdata); } else if (len > room) { /* Received packet's payload length is larger. * We can't accommodate it in created skb. */ pr_err("Data length is too large len %d room %d", len, room); kfree_skb(kim_gdata->rx_skb); } else { /* Packet header has non-zero payload length and * we have enough space in created skb. Lets read * payload data */ kim_gdata->rx_state = ST_W4_DATA; kim_gdata->rx_count = len; return len; } /* Change ST LL state to continue to process next * packet */ kim_gdata->rx_state = ST_W4_PACKET_TYPE; kim_gdata->rx_skb = NULL; kim_gdata->rx_count = 0; return 0; } /** * kim_int_recv - receive function called during firmware download * firmware download responses on different UART drivers * have been observed to come in bursts of different * tty_receive and hence the logic */ static void kim_int_recv(struct kim_data_s *kim_gdata, const unsigned char *data, long count) { const unsigned char *ptr; int len = 0, type = 0; unsigned char *plen; pr_debug("%s", __func__); /* Decode received bytes here */ ptr = data; if (unlikely(ptr == NULL)) { pr_err(" received null from TTY "); return; } while (count) { if (kim_gdata->rx_count) { len = min_t(unsigned int, kim_gdata->rx_count, count); memcpy(skb_put(kim_gdata->rx_skb, len), ptr, len); kim_gdata->rx_count -= len; count -= len; ptr += len; if (kim_gdata->rx_count) continue; /* Check ST RX state machine , where are we? */ switch (kim_gdata->rx_state) { /* Waiting for complete packet ? */ case ST_W4_DATA: pr_debug("Complete pkt received"); validate_firmware_response(kim_gdata); kim_gdata->rx_state = ST_W4_PACKET_TYPE; kim_gdata->rx_skb = NULL; continue; /* Waiting for Bluetooth event header ? */ case ST_W4_HEADER: plen = (unsigned char *)&kim_gdata->rx_skb->data[1]; pr_debug("event hdr: plen 0x%02x\n", *plen); kim_check_data_len(kim_gdata, *plen); continue; } /* end of switch */ } /* end of if rx_state */ switch (*ptr) { /* Bluetooth event packet? */ case 0x04: kim_gdata->rx_state = ST_W4_HEADER; kim_gdata->rx_count = 2; type = *ptr; break; default: pr_info("unknown packet"); ptr++; count--; continue; } ptr++; count--; kim_gdata->rx_skb = alloc_skb(1024+8, GFP_ATOMIC); if (!kim_gdata->rx_skb) { pr_err("can't allocate mem for new packet"); kim_gdata->rx_state = ST_W4_PACKET_TYPE; kim_gdata->rx_count = 0; return; } skb_reserve(kim_gdata->rx_skb, 8); kim_gdata->rx_skb->cb[0] = 4; kim_gdata->rx_skb->cb[1] = 0; } return; } static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name) { unsigned short version = 0, chip = 0, min_ver = 0, maj_ver = 0; const char read_ver_cmd[] = { 0x01, 0x01, 0x10, 0x00 }; long timeout; pr_debug("%s", __func__); reinit_completion(&kim_gdata->kim_rcvd); if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) { pr_err("kim: couldn't write 4 bytes"); return -EIO; } timeout = wait_for_completion_interruptible_timeout( &kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME)); if (timeout <= 0) { pr_err(" waiting for ver info- timed out or received signal"); return timeout ? -ERESTARTSYS : -ETIMEDOUT; } reinit_completion(&kim_gdata->kim_rcvd); /* the positions 12 & 13 in the response buffer provide with the * chip, major & minor numbers */ version = MAKEWORD(kim_gdata->resp_buffer[12], kim_gdata->resp_buffer[13]); chip = (version & 0x7C00) >> 10; min_ver = (version & 0x007F); maj_ver = (version & 0x0380) >> 7; if (version & 0x8000) maj_ver |= 0x0008; sprintf(bts_scr_name, "ti-connectivity/TIInit_%d.%d.%d.bts", chip, maj_ver, min_ver); /* to be accessed later via sysfs entry */ kim_gdata->version.full = version; kim_gdata->version.chip = chip; kim_gdata->version.maj_ver = maj_ver; kim_gdata->version.min_ver = min_ver; pr_info("%s", bts_scr_name); return 0; } static void skip_change_remote_baud(unsigned char **ptr, long *len) { unsigned char *nxt_action, *cur_action; cur_action
.. This work is licensed under a Creative Commons Attribution 4.0 International
.. License.
.. http://creativecommons.org/licenses/by/4.0
.. (c) OPNFV, Huawei Technologies Co.,Ltd and others.

*************************************
Yardstick Test Case Description TC071
*************************************

.. _cirros: https://download.cirros-cloud.net
.. _pktgen: https://www.kernel.org/doc/Documentation/networking/pktgen.txt
.. _cachestat: https://github.com/brendangregg/perf-tools/tree/master/fs

+-----------------------------------------------------------------------------+
|Latency, Cache Utilization, Throughput, Packet Loss                          |
|                                                                             |
+--------------+--------------------------------------------------------------+
|test case id  | OPNFV_YARDSTICK_TC071_Latency, Cache Utilization,            |
|              | Throughput,Packet Loss                                       |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|metric        | Number of flows, latency, throughput, Cache Utilization,     |
|              | packet loss                                                  |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|test purpose  | To evaluate the IaaS network performance with regards to     |
|              | flows and throughput, such as if and how different amounts   |
|              | of flows matter for the throughput between hosts on different|
|              | compute blades. Typically e.g. the performance of a vSwitch  |
|              | depends on the number of flows running through it. Also      |
|              | performance of other equipment or entities can depend        |
|              | on the number of flows or the packet sizes used.             |
|              | The purpose is also to be able to spot trends.               |
|              | Test results, graphs and similar shall be stored for         |
|              | comparison reasons and product evolution understanding       |
|              | between different OPNFV versions and/or configurations.      |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|configuration | file: opnfv_yardstick_tc071.yaml                             |
|              |                                                              |
|              | Packet size: 64 bytes                                        |
|              | Number of ports: 1, 10, 50, 100, 300, 500, 750 and 1000.     |
|              | The amount configured ports map from 2 up to 1001000 flows,  |
|              | respectively. Each port amount is run two times, for 20      |
|              | seconds each. Then the next port_amount is run, and so on.   |
|              | During the test Cache Utilization on both client and server, |
|              | and the network latency between the client and server are    |
|              | measured.                                                    |
|              | The client and server are distributed on different HW.       |
|              | For SLA max_ppm is set to 1000.                              |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|test tool     | pktgen                                                       |
|              |                                                              |
|              | Pktgen is not always part of a Linux distribution, hence it  |
|              | needs to be installed. It is part of the Yardstick Glance    |
|              | image.                                                       |
|              | (As an example see the /yardstick/tools/ directory for how   |
|              | to generate a Linux image with pktgen included.)             |
|              |                                                              |
|              | ping                                                         |
|              |                                                              |
|              | Ping is normally part of any Linux distribution, hence it    |
|              | doesn't need to be installed. It is also part of the         |
|              | Yardstick Glance image.                                      |
|              | (For example also a cirros_ image can be downloaded, it      |
|              | includes ping)                                               |
|              |                                                              |
|              | cachestat                                                    |
|              |                                                              |
|              | cachestat is not always part of a Linux distribution, hence  |
|              | it needs to be installed.                                    |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|references    | Ping man pages                                               |
|              |                                                              |
|              | pktgen_                                                      |
|              |                                                              |
|              | cachestat_                                                   |
|              |                                                              |
|              | ETSI-NFV-TST001                                              |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|applicability | Test can be configured with different packet sizes, amount   |
|              | of flows and test duration. Default values exist.            |
|              |                                                              |
|              | SLA (optional): max_ppm: The number of packets per million   |
|              | packets sent that are acceptable to lose, not received.      |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|pre-test      | The test case image needs to be installed into Glance        |
|conditions    | with pktgen included in it.                                  |
|              |                                                              |
|              | No POD specific requirements have been identified.           |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|test sequence | description and expected result                              |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|step 1        | The hosts are installed, as server and client. pktgen is     |
|              | invoked and logs are produced and stored.                    |
|              |                                                              |
|              | Result: Logs are stored.                                     |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|test verdict  | Fails only if SLA is not passed, or if there is a test case  |
|              | execution problem.                                           |
|              |                                                              |
+--------------+--------------------------------------------------------------+