// Copyright 2022 The gRPC 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. #ifndef GRPC_SRC_CORE_LIB_EVENT_ENGINE_POSIX_ENGINE_TRACED_BUFFER_LIST_H #define GRPC_SRC_CORE_LIB_EVENT_ENGINE_POSIX_ENGINE_TRACED_BUFFER_LIST_H #include <grpc/support/port_platform.h> #include <stdint.h> #include "absl/functional/any_invocable.h" #include "absl/status/status.h" #include "absl/types/optional.h" #include <grpc/support/time.h> #include "src/core/lib/event_engine/posix_engine/internal_errqueue.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/iomgr/port.h" namespace grpc_event_engine { namespace experimental { struct ConnectionMetrics { … }; struct BufferTimestamp { … }; struct Timestamps { … }; // TracedBuffer is a class to keep track of timestamps for a specific buffer in // the TCP layer. We are only tracking timestamps for Linux kernels and hence // this class would only be used by Linux platforms. For all other platforms, // TracedBuffer would be an empty class. // The timestamps collected are according to Timestamps declared above A // TracedBuffer list is kept track of using the head element of the list. If // *the head element of the list is nullptr, then the list is empty. #ifdef GRPC_LINUX_ERRQUEUE class TracedBufferList { … }; #else // GRPC_LINUX_ERRQUEUE // TracedBufferList implementation is a no-op for this platform. class TracedBufferList { public: void AddNewEntry(int32_t /*seq_no*/, int /*fd*/, void* /*arg*/) {} void ProcessTimestamp(struct sock_extended_err* /*serr*/, struct cmsghdr* /*opt_stats*/, struct scm_timestamping* /*tss*/) {} int Size() { return 0; } void Shutdown(void* /*remaining*/, absl::Status /*shutdown_err*/) {} }; #endif // GRPC_LINUX_ERRQUEUE // Sets the callback function to call when timestamps for a write are collected. // This is expected to be called atmost once. void TcpSetWriteTimestampsCallback( absl::AnyInvocable<void(void*, Timestamps*, absl::Status)>); } // namespace experimental } // namespace grpc_event_engine #endif // GRPC_SRC_CORE_LIB_EVENT_ENGINE_POSIX_ENGINE_TRACED_BUFFER_LIST_H