// Copyright 2025 Envoy Project Authors
//
// 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.

syntax = "proto3";

package envoy.extensions.network.socket_interface.v3;

import "google/protobuf/wrappers.proto";

import "udpa/annotations/status.proto";

option java_package = "io.envoyproxy.envoy.extensions.network.socket_interface.v3";
option java_outer_classname = "DefaultSocketInterfaceProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/network/socket_interface/v3;socket_interfacev3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: Default socket interface configuration]

// Configuration for default socket interface that relies on OS dependent syscall to create
// sockets.
message DefaultSocketInterface {
  // io_uring options. io_uring is only valid in Linux with at least kernel version 5.11. Otherwise,
  // Envoy will fall back to use the default socket API. If not set then io_uring will not be
  // enabled.
  IoUringOptions io_uring_options = 1;
}

message IoUringOptions {
  // The size for io_uring submission queues (SQ). io_uring is built with a fixed size in each
  // thread during configuration, and each io_uring operation creates a submission queue
  // entry (SQE). The default is 1000.
  google.protobuf.UInt32Value io_uring_size = 1;

  // Enable io_uring submission queue polling (SQPOLL). io_uring SQPOLL mode polls all SQEs in the
  // SQ in the kernel thread. io_uring SQPOLL mode may reduce latency and increase CPU usage as a
  // cost. The default is false.
  bool enable_submission_queue_polling = 2;

  // The size of an io_uring socket's read buffer. Each io_uring read operation will allocate a
  // buffer of the given size. If the given buffer is too small, the socket will have read multiple
  // times for all the data. The default is 8192.
  google.protobuf.UInt32Value read_buffer_size = 3;

  // The write timeout of an io_uring socket on closing in ms. io_uring writes and closes
  // asynchronously. If the remote stops reading, the io_uring write operation may never complete.
  // The operation is canceled and the socket is closed after the timeout. The default is 1000.
  google.protobuf.UInt32Value write_timeout_ms = 4;
}
