aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/virtio/vhost_user_api.c
AgeCommit message (Collapse)AuthorFilesLines
2019-07-31devices interface tests: vhosst GSO supportSteven Luong1-3/+19
Add gso option in create vhost interface to support gso and checksum offload. Tested with the following startup options in qemu: csum=on,gso=on,guest_csum=on,guest_tso4=on,guest_tso6=on,guest_ufo=on, host_tso4=on,host_tso6=on,host_ufo=on Type: feature Change-Id: I9ba1ee33677a694c4a0dfe66e745b098995902b8 Signed-off-by: Steven Luong <sluong@cisco.com>
2019-04-10API: Fix shared memory only action handlers.Ole Troan1-22/+0
Some API action handlers called vl_msg_ai_send_shmem() directly. That breaks Unix domain socket API transport. A couple (bond / vhost) also tried to send a sw_interface_event directly, but did not send the message to all that had registred interest. That scheme never worked correctly. Refactored and improved the interface event code. Change-Id: Idb90edfd8703c6ae593b36b4eeb4d3ed7da5c808 Signed-off-by: Ole Troan <ot@cisco.com>
2019-04-08fixing typosJim Thompson1-1/+1
Change-Id: I215e1e0208a073db80ec6f87695d734cf40fabe3 Signed-off-by: Jim Thompson <jim@netgate.com>
2019-03-15Revert "API: Cleanup APIs interface.api"Ole Trøan1-1/+2
This reverts commit e63325e3ca03c847963863446345e6c80a2c0cfd. Allow time for CSIT to accommodate. Change-Id: I59435e4ab5e05e36a2796c3bf44889b5d4823cc2 Signed-off-by: ot@cisco.com
2019-03-15API: Cleanup APIs interface.apiJakub Grajciar1-2/+1
Use of consistent API types for interface.api Change-Id: Ieb54cebb4ac96b432a3f0b41596718aa2f34885b Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
2019-02-21vhost: VPP stalls with vhost performing control plane actionsSteven Luong1-0/+3
Symptom ------- With NDR traffic blasting at VPP, bringing up a new VM with vhost connection to VPP causes packet drops. I am able to recreate this problem easily using a simple setup like this. TREX-------------- switch ---- VPP |---------------| |-------| Cause ----- The reason for the packet drops is due to vhost holding onto the worker barrier lock for too long in vhost_user_socket_read(). There are quite a few of system calls inside the routine. At the end of the routine, it unconditionally calls vhost_user_update_iface_state() for all message types. vhost_user_update_iface_state() also unconditionally calls vhost_user_rx_thread_placement() and vhost_user_tx_thread_placement(). vhost_user_rx_thread_placement scraps out all existing cpu/queue mappings for the interface and creates brand new cpu/queue mappings for the interface. This process is very disruptive and very expensive. In my opinion, this area of code needs a makeover. Fixes ----- * vhost_user_socket_read() is rewritten that it should not hold onto the worker barrier lock for system calls, or at least minimize the need for doing it. * Remove the call to vhost_user_update_iface_state as a default route at the end of vhost_user_socket_read(). There is only a couple of message types which really need to call vhost_user_update_iface_state(). We put the call to those message types which need it. * Remove vhost_user_rx_thread_placement() and vhost_user_tx_thread_placement from vhost_user_update_iface_state(). There is no need to repetatively change the cpu/queue mappings. * vhost_user_rx_thread_placement() is actually quite expensive. It should be called only once per queue for the interface. There is no need to scrap the existing cpu/queue mappings and create new cpu/queue mappings when the additional queues becomes active/enable. * Change to create the cpu/queue mappings for the first RX when the interface is created. Dont remove the cpu/queue mapping when the interface is disconnected. Remove the cpu/queue mapping only when the interface is deleted. The create vhost user interface CLI also has some very expensive system calls if the command is entered with the optional keyword "server" As a bonus, This patch makes the create vhost user interface binary-api and CLI thread safe. Do the protection for the small amount of code which is thread unsafe. Change-Id: I4a19cbf7e9cc37ea01286169882e5603e6d7eb77 Signed-off-by: Steven Luong <sluong@cisco.com>
2018-10-23c11 safe string handling supportDave Barach1-2/+2
Change-Id: Ied34720ca5a6e6e717eea4e86003e854031b6eab Signed-off-by: Dave Barach <dave@barachs.net>
2018-09-20vhost-user: Add disable feature support in apiMohsin Kazmi1-1/+11
Two flags to disable mergable rx buffers and indirect descriptors are added to api. Change-Id: Iba0ee9c48d19dfc3d3420a3fdaf44a1a1d325e99 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
2018-07-08vhost: Add multi-versioning supportMohsin Kazmi1-1/+1
It also refactors the vhost code which was in one big file vhost-user.c. Receive side code is in vhost_user_input.c and Transmit side code is in vhost_user_output.c Change-Id: I1b539b5008685889723e228265786a2a3e9f3a78 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
2018-01-11api: remove transport specific code from handlersFlorin Coras1-11/+12
This does not update api client code. In other words, if the client assumes the transport is shmem based, this patch does not change that. Furthermore, code that checks queue size, for tail dropping, is not updated. Done for the following apis: Plugins - acl - gtpu - memif - nat - pppoe VNET - bfd - bier - tapv2 - vhost user - dhcp - flow - geneve - ip - punt - ipsec/ipsec-gre - l2 - l2tp - lisp-cp/one-cp - lisp-gpe - map - mpls - policer - session - span - udp - tap - vxlan/vxlan-gpe - interface VPP - api/api.c OAM - oam_api.c Stats - stats.c Change-Id: I0e33ecefb2bdab0295698c0add948068a5a83345 Signed-off-by: Florin Coras <fcoras@cisco.com>
2018-01-09api: refactor vlibmemoryFlorin Coras1-6/+4
- separate client/server code for both memory and socket apis - separate memory api code from generic vlib api code - move unix_shared_memory_fifo to svm and rename to svm_fifo_t - overall declutter Change-Id: I90cdd98ff74d0787d58825b914b0f1eafcfa4dc2 Signed-off-by: Florin Coras <fcoras@cisco.com>
2017-08-18Use correct msg ID in the sw-interface-event from TAP and VHOSTNeale Ranns1-1/+1
Change-Id: I0124fa264f7f390fc7cd9722da59be03116831c5 Signed-off-by: Neale Ranns <nranns@cisco.com>
2017-08-11Dedicated SW Interface EventNeale Ranns1-3/+3
Change-Id: I06a10a4291e61aec3f1396d2514ed6fe3901897a Signed-off-by: Neale Ranns <neale.ranns@cisco.com> Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
2017-05-22vhost: migrate to use device infra for worker thread assignment, rx-mode.Steven1-5/+2
and add adaptive mode support to receive queue - Migrate vhost to use device infra which does the interface/queue to worker thread assignment. - Retire vhost thread CLI and corresponding code which assigns interface/queue to worker thread. set interface placement should be used instead to customize the interface/queue to worker thread assignment. - Retire vhost interrupt/polling option when creating vhost-user interface. Instead, set interface rx-mode should be used. - Add code in vnet_device_input_unassign_thread to change the node state to interrupt if the last polling interface has left the worker thread for the device of the corresponding interface/queue. - Add adaptive mode support. The node state is set to interrupt initially. When the scheduler detects a burst of traffic, it switches the input node to polling. Then we inform the device that we don't need interrupt notification. When the traffic subsides, the scheduler switches the input node back to interrupt. Then we immediately tell the driver that we want interrupt notification again. - Remove some duplicate code in vlib/main.c Change-Id: Id19bb1b9e50e6521c6464f470f5825c26924d3a8 Signed-off-by: Steven <sluong@cisco.com>
2017-03-08vhost: binary API changes for interrupt modeSteven1-2/+5
Add operation_mode for create_vhost_user_if, modify_vhost_user_if, and sw_interface_vhost_user_details. Only polling mode is supported for these APIs. Other mode is rejected and gets VNET_API_ERROR_UNIMPLEMENTED error. Change-Id: I0596f4e2c087aa2b6f78eb3e0b63910b1859641e Signed-off-by: Steven <sluong@cisco.com>
2017-03-02Clean up binary api message handler registration issuesDave Barach1-9/+1
Removed a fair number of "BUG" message handlers, due to conflicts with actual message handlers in api_format.c. Vpp itself had no business receiving certain messages, up to the point where we started building in relevant code from vpp_api_test. Eliminated all but one duplicate registration complaint. That one needs attention from the vxlan team since the duplicated handlers have diverged. Change-Id: Iafce5429d2f906270643b4ea5f0130e20beb4d1d Signed-off-by: Dave Barach <dave@barachs.net>
2016-12-28Reorganize source tree to use single autotools instanceDamjan Marion1-0/+262
Change-Id: I7b51f88292e057c6443b12224486f2d0c9f8ae23 Signed-off-by: Damjan Marion <damarion@cisco.com>
ing.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (c) 2015-2016 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

option version = "1.0.0";

/** \brief Add/Delete classification table request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_add- if non-zero add the table, else delete it
    @param del_chain - if non-zero delete the whole chain of tables
    @param table_index - if add, reuturns index of the created table, else specifies the table to delete  
    @param nbuckets - number of buckets when adding a table
    @param memory_size - memory size when adding a table
    @param match_n_vectors - number of match vectors
    @param next_table_index - index of next table
    @param miss_next_index - index of miss table
    @param current_data_flag - option to use current node's packet payload
            as the starting point from where packets are classified,
            This option is only valid for L2/L3 input ACL for now.
            0: by default, classify data from the buffer's start location
            1: classify packets from VPP node’s current data pointer
    @param current_data_offset - a signed value to shift the start location of
            the packet to be classified
            For example, if input IP ACL node is used, L2 header’s first byte
            can be accessible by configuring current_data_offset to -14
            if there is no vlan tag.
            This is valid only if current_data_flag is set to 1.
    @param mask[] - match mask
*/
define classify_add_del_table
{
  u32 client_index;
  u32 context;
  u8 is_add;
  u8 del_chain;
  u32 table_index;
  u32 nbuckets;
  u32 memory_size;
  u32 skip_n_vectors;
  u32 match_n_vectors;
  u32 next_table_index;
  u32 miss_next_index;
  u32 current_data_flag;
  i32 current_data_offset;
  u8 mask[0];
};

/** \brief Add/Delete classification table response
    @param context - sender context, to match reply w/ request
    @param retval - return code for the table add/del requst
    @param new_table_index - for add, returned index of the new table
    @param skip_n_vectors - for add, returned value of skip_n_vectors in table
    @param match_n_vectors -for add, returned value of match_n_vectors in table
*/
define classify_add_del_table_reply
{
  u32 context;
  i32 retval;
  u32 new_table_index;
  u32 skip_n_vectors;
  u32 match_n_vectors;
};

/** \brief Classify add / del session request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_add - add session if non-zero, else delete
    @param table_index - index of the table to add/del the session, required
    @param hit_next_index - for add, hit_next_index of new session, required
    @param opaque_index - for add, opaque_index of new session
    @param advance -for add, advance value for session
    @param action -
           0: no action (by default)
              metadata is not used.
           1: Classified IP packets will be looked up from the
              specified ipv4 fib table (configured by metadata as VRF id).
              Only valid for L3 input ACL node
           2: Classified IP packets will be looked up from the
              specified ipv6 fib table (configured by metadata as VRF id).
              Only valid for L3 input ACL node
           3: Classified packet will be steered to source routig policy
              of given index (in metadata).
              This is only valid for IPv6 packets redirected to a source
              routing node.
    @param metadata - valid only if action != 0
           VRF id if action is 1 or 2.
           sr policy index if action is 3.
    @param match[] - for add, match value for session, required
*/
autoreply define classify_add_del_session
{
  u32 client_index;
  u32 context;
  u8 is_add;
  u32 table_index;
  u32 hit_next_index;
  u32 opaque_index;
  i32 advance;
  u8 action;
  u32 metadata;
  u8 match[0];
};

/** \brief Set/unset policer classify interface
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - interface to set/unset policer classify
    @param ip4_table_index - ip4 classify table index (~0 for skip)
    @param ip6_table_index - ip6 classify table index (~0 for skip)
    @param l2_table_index  -  l2 classify table index (~0 for skip)
    @param is_add - Set if non-zero, else unset
    Note: User is recommeneded to use just one valid table_index per call.
          (ip4_table_index, ip6_table_index, or l2_table_index)
*/
autoreply define policer_classify_set_interface
{
  u32 client_index;
  u32 context;
  u32 sw_if_index;
  u32 ip4_table_index;
  u32 ip6_table_index;
  u32 l2_table_index;
  u8 is_add;
};

/** \brief Get list of policer classify interfaces and tables
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param type - classify table type
*/
define policer_classify_dump
{
  u32 client_index;
  u32 context;
  u8 type;
};

/** \brief Policer iclassify operational state response.
    @param context - sender context, to match reply w/ request
    @param sw_if_index - software interface index
    @param table_index - classify table index
*/
define policer_classify_details
{
  u32 context;
  u32 sw_if_index;
  u32 table_index;
};

/** \brief Classify get table IDs request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
*/
define classify_table_ids
{
  u32 client_index;
  u32 context;
};

/** \brief Reply for classify get table IDs request
    @param context - sender context which was passed in the request
    @param count - number of ids returned in response
    @param ids - array of classify table ids
*/
define classify_table_ids_reply
{
  u32 context;
  i32 retval;
  u32 count;
  u32 ids[count];
};

/** \brief Classify table ids by interface index request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - index of the interface
*/
define classify_table_by_interface
{
  u32 client_index;
  u32 context;
  u32 sw_if_index;
};

/** \brief Reply for classify table id by interface index request
    @param context - sender context which was passed in the request
    @param count - number of ids returned in response
    @param sw_if_index - index of the interface
    @param l2_table_id - l2 classify table index
    @param ip4_table_id - ip4 classify table index
    @param ip6_table_id - ip6 classify table index
*/
define classify_table_by_interface_reply
{
  u32 context;
  i32 retval;
  u32 sw_if_index;
  u32 l2_table_id;
  u32 ip4_table_id;
  u32 ip6_table_id;
};

/** \brief Classify table info
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param table_id - classify table index
*/
define classify_table_info
{
  u32 client_index;
  u32 context;
  u32 table_id;
};

/** \brief Reply for classify table info request
    @param context - sender context which was passed in the request
    @param count - number of ids returned in response
    @param table_id - classify table index
    @param nbuckets - number of buckets when adding a table
    @param match_n_vectors - number of match vectors
    @param skip_n_vectors - number of skip_n_vectors
    @param active_sessions - number of sessions (active entries)
    @param next_table_index - index of next table
    @param miss_next_index - index of miss table
    @param mask[] - match mask
*/
define classify_table_info_reply
{
  u32 context;
  i32 retval;
  u32 table_id;
  u32 nbuckets;
  u32 match_n_vectors;
  u32 skip_n_vectors;
  u32 active_sessions;
  u32 next_table_index;
  u32 miss_next_index;
  u32 mask_length;
  u8 mask[mask_length];
};

/** \brief Classify sessions dump request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param table_id - classify table index
*/
define classify_session_dump
{
  u32 client_index;
  u32 context;
  u32 table_id;
};

/** \brief Reply for classify table session dump request
    @param context - sender context which was passed in the request
    @param count - number of ids returned in response
    @param table_id - classify table index
    @param hit_next_index - hit_next_index of session
    @param opaque_index - for add, opaque_index of session
    @param advance - advance value of session
    @param match[] - match value for session
*/
define classify_session_details
{
  u32 context;
  i32 retval;
  u32 table_id;
  u32 hit_next_index;
  i32 advance;
  u32 opaque_index;
  u32 match_length;
  u8 match[match_length];
};

/** \brief Set/unset flow classify interface
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - interface to set/unset flow classify
    @param ip4_table_index - ip4 classify table index (~0 for skip)
    @param ip6_table_index - ip6 classify table index (~0 for skip)
    @param l2_table_index  -  l2 classify table index (~0 for skip)
    @param is_add - Set if non-zero, else unset
    Note: User is recommeneded to use just one valid table_index per call.
          (ip4_table_index, ip6_table_index, or l2_table_index)
*/
autoreply define flow_classify_set_interface {
    u32 client_index;
    u32 context;
    u32 sw_if_index;
    u32 ip4_table_index;
    u32 ip6_table_index;
    u8  is_add;
};

/** \brief Get list of flow classify interfaces and tables
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param type - classify table type
*/
define flow_classify_dump {
    u32 client_index;
    u32 context;
    u8 type;
};

/** \brief Flow classify operational state response.
    @param context - sender context, to match reply w/ request
    @param sw_if_index - software interface index
    @param table_index - classify table index
*/
define flow_classify_details {
    u32 context;
    u32 sw_if_index;
    u32 table_index;
};

/** \brief Set/unset the classification table for an interface request 
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_ipv6 - ipv6 if non-zero, else ipv4
    @param sw_if_index - interface to associate with the table
    @param table_index - index of the table, if ~0 unset the table
*/
autoreply define classify_set_interface_ip_table
{
  u32 client_index;
  u32 context;
  u8 is_ipv6;
  u32 sw_if_index;
  u32 table_index;		/* ~0 => off */
};

/** \brief Set/unset l2 classification tables for an interface request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - interface to set/unset tables for
    @param ip4_table_index - ip4 index, use ~0 for all 3 indexes to unset
    @param ip6_table_index - ip6 index
    @param other_table_index - other index
*/
autoreply define classify_set_interface_l2_tables
{
  u32 client_index;
  u32 context;
  u32 sw_if_index;
  /* 3 x ~0 => off */
  u32 ip4_table_index;
  u32 ip6_table_index;
  u32 other_table_index;
  u8 is_input;
};

/** \brief Set/unset input ACL interface
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - interface to set/unset input ACL
    @param ip4_table_index - ip4 classify table index (~0 for skip)
    @param ip6_table_index - ip6 classify table index (~0 for skip)
    @param l2_table_index  -  l2 classify table index (~0 for skip)
    @param is_add - Set input ACL if non-zero, else unset
    Note: User is recommeneded to use just one valid table_index per call.
          (ip4_table_index, ip6_table_index, or l2_table_index)
*/
autoreply define input_acl_set_interface
{
  u32 client_index;
  u32 context;
  u32 sw_if_index;
  u32 ip4_table_index;
  u32 ip6_table_index;
  u32 l2_table_index;
  u8 is_add;
};

/** \brief Set/unset output ACL interface
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - interface to set/unset output ACL
    @param ip4_table_index - ip4 classify table index (~0 for skip)
    @param ip6_table_index - ip6 classify table index (~0 for skip)
    @param l2_table_index  -  l2 classify table index (~0 for skip)
    @param is_add - Set output ACL if non-zero, else unset
    Note: User is recommeneded to use just one valid table_index per call.
          (ip4_table_index, ip6_table_index, or l2_table_index)
*/
autoreply define output_acl_set_interface
{
  u32 client_index;
  u32 context;
  u32 sw_if_index;
  u32 ip4_table_index;
  u32 ip6_table_index;
  u32 l2_table_index;
  u8 is_add;
};

/*
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */